Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
5dcbd051ff
103
app/build.gradle
103
app/build.gradle
|
@ -22,14 +22,6 @@ jacoco {
|
|||
toolVersion = "0.8.3"
|
||||
}
|
||||
|
||||
ext {
|
||||
powermockVersion = "1.7.3"
|
||||
dexmakerVersion = "1.2"
|
||||
retrofit2Version = '2.9.0'
|
||||
okhttp3Version = '4.7.2'
|
||||
}
|
||||
|
||||
|
||||
repositories {
|
||||
jcenter { url "https://jcenter.bintray.com/" }
|
||||
mavenCentral()
|
||||
|
@ -128,7 +120,7 @@ android {
|
|||
targetSdkVersion 28
|
||||
multiDexEnabled true
|
||||
versionCode 1500
|
||||
version "2.7.0"
|
||||
version "2.7.2-dev"
|
||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
||||
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'
|
||||
|
@ -230,11 +222,9 @@ android {
|
|||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
flatDir {
|
||||
dirs 'libs'
|
||||
}
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,66 +237,11 @@ dependencies {
|
|||
implementation project(':danar')
|
||||
implementation project(':rileylink')
|
||||
implementation project(':medtronic')
|
||||
implementation project(':omnipod')
|
||||
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
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.firebase:firebase-core:17.4.3'
|
||||
implementation 'com.google.firebase:firebase-auth:19.3.1'
|
||||
implementation 'com.google.firebase:firebase-database:19.3.1'
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.biometric:biometric:1.0.1'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||
implementation 'androidx.gridlayout:gridlayout:1.0.0'
|
||||
implementation 'androidx.percentlayout:percentlayout:1.0.0'
|
||||
implementation "androidx.preference:preference-ktx:1.1.1"
|
||||
implementation "androidx.activity:activity-ktx:${activityVersion}"
|
||||
implementation "androidx.fragment:fragment:${fragmentVersion}"
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'com.google.android.material:material:1.1.0'
|
||||
|
||||
implementation "io.reactivex.rxjava2:rxandroid:${rxandroid_version}"
|
||||
|
||||
implementation "com.j256.ormlite:ormlite-core:${ormLiteVersion}"
|
||||
implementation "com.j256.ormlite:ormlite-android:${ormLiteVersion}"
|
||||
implementation("com.github.tony19:logback-android-classic:1.1.1-6") {
|
||||
exclude group: "com.google.android", module: "android"
|
||||
}
|
||||
implementation 'org.apache.commons:commons-lang3:3.10'
|
||||
implementation 'org.slf4j:slf4j-api:1.7.30'
|
||||
// Graphview cannot be upgraded
|
||||
implementation "com.jjoe64:graphview:4.0.1"
|
||||
implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.2.2"
|
||||
implementation 'com.madgag.spongycastle:core:1.58.0.0'
|
||||
// Omnipod wizard
|
||||
implementation(name: "com.atech-software.android.library.wizardpager-1.1.4", ext: "aar")
|
||||
implementation("com.google.android:flexbox:0.3.0") {
|
||||
exclude group: "com.android.support"
|
||||
}
|
||||
implementation("io.socket:socket.io-client:1.0.0") {
|
||||
// excluding org.json which is provided by Android
|
||||
exclude group: "org.json", module: "json"
|
||||
}
|
||||
implementation "com.google.code.gson:gson:2.8.6"
|
||||
implementation('com.google.guava:guava:29.0-jre') {
|
||||
exclude group: "com.google.code.findbugs", module: "jsr305"
|
||||
}
|
||||
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
||||
|
||||
implementation 'net.danlew:android.joda:2.10.6'
|
||||
|
||||
implementation 'org.mozilla:rhino:1.7.12'
|
||||
|
||||
implementation 'com.github.DavidProdinger:weekdays-selector:1.1.0'
|
||||
|
||||
implementation 'com.github.kenglxn.QRGen:android:2.6.0'
|
||||
implementation 'com.eatthepath:java-otp:0.2.0'
|
||||
|
||||
testImplementation "junit:junit:4.13"
|
||||
testImplementation "junit:junit:$junit_version"
|
||||
testImplementation 'org.json:json:20200518'
|
||||
testImplementation "org.mockito:mockito-core:2.8.47"
|
||||
testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}"
|
||||
|
@ -321,31 +256,16 @@ dependencies {
|
|||
testImplementation "org.skyscreamer:jsonassert:1.5.0"
|
||||
testImplementation "org.hamcrest:hamcrest-all:1.3"
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
|
||||
|
||||
// new for tidepool
|
||||
implementation "com.squareup.okhttp3:okhttp:$okhttp3Version"
|
||||
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp3Version"
|
||||
implementation "com.squareup.retrofit2:retrofit:$retrofit2Version"
|
||||
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit2Version"
|
||||
implementation "com.squareup.retrofit2:converter-gson:$retrofit2Version"
|
||||
|
||||
// Phone checker
|
||||
implementation 'com.scottyab:rootbeer-lib:0.0.8'
|
||||
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha03'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test:rules:1.3.0-beta01'
|
||||
androidTestImplementation "androidx.test.ext:junit:$androidx_junit"
|
||||
androidTestImplementation "androidx.test:rules:$androidx_rules"
|
||||
androidTestImplementation 'com.google.code.findbugs:jsr305:3.0.2'
|
||||
|
||||
/* Dagger2 - We are going to use dagger.android which includes
|
||||
* support for Activity and fragment injection so we need to include
|
||||
* the following dependencies */
|
||||
implementation "com.google.dagger:dagger-android:$dagger_version"
|
||||
implementation "com.google.dagger:dagger-android-support:$dagger_version"
|
||||
|
||||
|
||||
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
|
||||
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger_version"
|
||||
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
|
||||
|
@ -354,15 +274,6 @@ dependencies {
|
|||
kapt "com.google.dagger:dagger-compiler:$dagger_version"
|
||||
|
||||
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
||||
|
||||
//WorkManager
|
||||
implementation 'androidx.work:work-runtime:2.3.4'
|
||||
implementation 'androidx.work:work-runtime-ktx:2.3.4'
|
||||
implementation 'androidx.work:work-rxjava2:2.3.4'
|
||||
|
||||
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:1.1.0'
|
||||
|
||||
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="info.nightscout.androidaps">
|
||||
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
|
@ -71,6 +72,10 @@
|
|||
<activity android:name=".activities.ProfileHelperActivity"
|
||||
android:theme="@style/ProfileHelperAppTheme" />
|
||||
<activity android:name=".activities.StatsActivity" />
|
||||
<activity
|
||||
android:name="com.google.firebase.auth.internal.FederatedSignInActivity"
|
||||
tools:replace="android:launchMode"
|
||||
android:launchMode="standard" />
|
||||
|
||||
<!-- Receive new BG readings from other local apps -->
|
||||
<receiver
|
||||
|
|
|
@ -110,7 +110,7 @@ function enable_smb(
|
|||
return false;
|
||||
}
|
||||
|
||||
var determine_basal = function determine_basal(glucose_status, currenttemp, iob_data, profile, autosens_data, meal_data, tempBasalFunctions, microBolusAllowed, reservoir_data, currentTime) {
|
||||
var determine_basal = function determine_basal(glucose_status, currenttemp, iob_data, profile, autosens_data, meal_data, tempBasalFunctions, microBolusAllowed, reservoir_data, currentTime, isSaveCgmSource) {
|
||||
var rT = {}; //short for requestedTemp
|
||||
|
||||
var deliverAt = new Date();
|
||||
|
@ -143,7 +143,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
|||
rT.reason = "If current system time "+systemTime+" is correct, then BG data is too old. The last BG data was read "+minAgo+"m ago at "+bgTime;
|
||||
// if BG is too old/noisy, or is changing less than 1 mg/dL/5m for 45m, cancel any high temps and shorten any long zero temps
|
||||
//cherry pick from oref upstream dev cb8e94990301277fb1016c778b4e9efa55a6edbc
|
||||
} else if ( bg > 60 && glucose_status.delta == 0 && glucose_status.short_avgdelta > -1 && glucose_status.short_avgdelta < 1 && glucose_status.long_avgdelta > -1 && glucose_status.long_avgdelta < 1 ) {
|
||||
} else if ( bg > 60 && glucose_status.delta == 0 && glucose_status.short_avgdelta > -1 && glucose_status.short_avgdelta < 1 && glucose_status.long_avgdelta > -1 && glucose_status.long_avgdelta < 1 && !isSaveCgmSource) {
|
||||
if ( glucose_status.last_cal && glucose_status.last_cal < 3 ) {
|
||||
rT.reason = "CGM was just calibrated";
|
||||
} else {
|
||||
|
|
|
@ -2,3 +2,5 @@
|
|||
51:6D:12:67:4C:27:F4:9B:9F:E5:42:9B:01:B3:98:E4:66:2B:85:B7:A8:DD:70:32:B7:6A:D7:97:9A:0D:97:10
|
||||
#Leaked
|
||||
55:5D:70:C9:BE:10:41:7E:4B:01:A9:C4:C6:44:4A:F8:69:71:35:25:ED:95:23:16:C7:15:E8:EB:C6:08:FC:B1
|
||||
E0:71:A3:6E:96:60:5A:FC:B3:77:DB:2F:C4:E0:92:F3:39:A6:27:24:91:F5:7E:BB:55:9B:60:C6:CC:A3:03:41
|
||||
32:99:61:C4:A0:92:E8:D2:C7:65:04:74:04:17:7E:2D:2A:16:2A:5A:63:48:69:6A:0A:C4:53:3C:7C:78:22:95
|
||||
|
|
|
@ -27,9 +27,10 @@ import androidx.viewpager2.widget.ViewPager2
|
|||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import com.joanzapata.iconify.Iconify
|
||||
import com.joanzapata.iconify.fonts.FontAwesomeModule
|
||||
import info.nightscout.androidaps.activities.ProfileHelperActivity
|
||||
import dev.doubledot.doki.ui.DokiActivity
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||
import info.nightscout.androidaps.activities.PreferencesActivity
|
||||
import info.nightscout.androidaps.activities.ProfileHelperActivity
|
||||
import info.nightscout.androidaps.activities.SingleFragmentActivity
|
||||
import info.nightscout.androidaps.activities.StatsActivity
|
||||
import info.nightscout.androidaps.events.EventAppExit
|
||||
|
@ -45,6 +46,8 @@ 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.general.maintenance.ImportExportPrefs
|
||||
import info.nightscout.androidaps.plugins.general.maintenance.PrefsFileContract
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
||||
import info.nightscout.androidaps.setupwizard.SetupWizardActivity
|
||||
|
@ -68,6 +71,7 @@ import javax.inject.Inject
|
|||
import kotlin.system.exitProcess
|
||||
|
||||
class MainActivity : NoSplashAppCompatActivity() {
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
|
@ -87,10 +91,17 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||
@Inject lateinit var signatureVerifierPlugin: SignatureVerifierPlugin
|
||||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var importExportPrefs: ImportExportPrefs
|
||||
|
||||
private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle
|
||||
private var pluginPreferencesMenuItem: MenuItem? = null
|
||||
|
||||
val callForPrefFile = registerForActivityResult(PrefsFileContract()) {
|
||||
it?.let {
|
||||
importExportPrefs.importSharedPreferences(this, it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Iconify.with(FontAwesomeModule())
|
||||
|
@ -126,16 +137,17 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
if (it.recreate) recreate()
|
||||
else setupViews()
|
||||
setWakeLock()
|
||||
}) { fabricPrivacy::logException }
|
||||
}, fabricPrivacy::logException)
|
||||
)
|
||||
disposable.add(rxBus
|
||||
.toObservable(EventPreferenceChange::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ processPreferenceChange(it) }) { fabricPrivacy::logException }
|
||||
.subscribe({ processPreferenceChange(it) }, fabricPrivacy::logException)
|
||||
)
|
||||
if (!sp.getBoolean(R.string.key_setupwizard_processed, false) && !isRunningRealPumpTest()) {
|
||||
val intent = Intent(this, SetupWizardActivity::class.java)
|
||||
startActivity(intent)
|
||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
|
||||
startActivity(Intent(this, SetupWizardActivity::class.java))
|
||||
})
|
||||
}
|
||||
androidPermission.notifyForStoragePermission(this)
|
||||
androidPermission.notifyForBatteryOptimizationPermission(this)
|
||||
|
@ -163,8 +175,8 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
override fun onResume() {
|
||||
super.onResume()
|
||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.APPLICATION, null,
|
||||
UIRunnable(Runnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() }) }),
|
||||
UIRunnable(Runnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() }) })
|
||||
UIRunnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed)) { finish() } },
|
||||
UIRunnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed)) { finish() } }
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -183,14 +195,14 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
val pageAdapter = TabPageAdapter(this)
|
||||
main_navigation_view.setNavigationItemSelectedListener { true }
|
||||
val menu = main_navigation_view.menu.also { it.clear() }
|
||||
for (p in activePlugin.pluginsList) {
|
||||
for (p in activePlugin.getPluginsList()) {
|
||||
pageAdapter.registerNewFragment(p)
|
||||
if (p.isEnabled() && p.hasFragment() && !p.isFragmentVisible() && !p.pluginDescription.neverVisible) {
|
||||
val menuItem = menu.add(p.name)
|
||||
menuItem.isCheckable = true
|
||||
menuItem.setOnMenuItemClickListener {
|
||||
val intent = Intent(this, SingleFragmentActivity::class.java)
|
||||
intent.putExtra("plugin", activePlugin.pluginsList.indexOf(p))
|
||||
intent.putExtra("plugin", activePlugin.getPluginsList().indexOf(p))
|
||||
startActivity(intent)
|
||||
main_drawer_layout.closeDrawers()
|
||||
true
|
||||
|
@ -228,7 +240,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
if (permissions.isNotEmpty()) {
|
||||
if (ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED) {
|
||||
when (requestCode) {
|
||||
AndroidPermission.CASE_STORAGE -> //show dialog after permission is granted
|
||||
AndroidPermission.CASE_STORAGE -> //show dialog after permission is granted
|
||||
OKDialog.show(this, "", resourceHelper.gs(R.string.alert_dialog_storage_permission_text))
|
||||
|
||||
AndroidPermission.CASE_LOCATION, AndroidPermission.CASE_SMS, AndroidPermission.CASE_BATTERY, AndroidPermission.CASE_PHONE_STATE, AndroidPermission.CASE_SYSTEM_WINDOW -> {
|
||||
|
@ -263,8 +275,8 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.nav_preferences -> {
|
||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, Runnable {
|
||||
R.id.nav_preferences -> {
|
||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
|
||||
val i = Intent(this, PreferencesActivity::class.java)
|
||||
i.putExtra("id", -1)
|
||||
startActivity(i)
|
||||
|
@ -272,17 +284,19 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
return true
|
||||
}
|
||||
|
||||
R.id.nav_historybrowser -> {
|
||||
R.id.nav_historybrowser -> {
|
||||
startActivity(Intent(this, HistoryBrowseActivity::class.java))
|
||||
return true
|
||||
}
|
||||
|
||||
R.id.nav_setupwizard -> {
|
||||
startActivity(Intent(this, SetupWizardActivity::class.java))
|
||||
R.id.nav_setupwizard -> {
|
||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
|
||||
startActivity(Intent(this, SetupWizardActivity::class.java))
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
R.id.nav_about -> {
|
||||
R.id.nav_about -> {
|
||||
var message = "Build: ${BuildConfig.BUILDVERSION}\n"
|
||||
message += "Flavor: ${BuildConfig.FLAVOR}${BuildConfig.BUILD_TYPE}\n"
|
||||
message += "${resourceHelper.gs(R.string.configbuilder_nightscoutversion_label)} ${nsSettingsStatus.nightscoutVersionName}"
|
||||
|
@ -295,14 +309,15 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
.setIcon(iconsProvider.getIcon())
|
||||
.setMessage(messageSpanned)
|
||||
.setPositiveButton(resourceHelper.gs(R.string.ok), null)
|
||||
.create().also {
|
||||
it.show()
|
||||
(it.findViewById<View>(android.R.id.message) as TextView).movementMethod = LinkMovementMethod.getInstance()
|
||||
.setNeutralButton(resourceHelper.gs(R.string.cta_dont_kill_my_app_info)) { _, _ -> DokiActivity.start(context = this@MainActivity) }
|
||||
.create().apply {
|
||||
show()
|
||||
findViewById<TextView>(android.R.id.message)?.movementMethod = LinkMovementMethod.getInstance()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
R.id.nav_exit -> {
|
||||
R.id.nav_exit -> {
|
||||
aapsLogger.debug(LTag.CORE, "Exiting")
|
||||
rxBus.send(EventAppExit())
|
||||
finish()
|
||||
|
@ -312,7 +327,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
R.id.nav_plugin_preferences -> {
|
||||
val plugin = (main_pager.adapter as TabPageAdapter).getPluginAt(main_pager.currentItem)
|
||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, Runnable {
|
||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
|
||||
val i = Intent(this, PreferencesActivity::class.java)
|
||||
i.putExtra("id", plugin.preferencesId)
|
||||
startActivity(i)
|
||||
|
@ -325,12 +340,12 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
return true
|
||||
}
|
||||
*/
|
||||
R.id.nav_defaultprofile -> {
|
||||
R.id.nav_defaultprofile -> {
|
||||
startActivity(Intent(this, ProfileHelperActivity::class.java))
|
||||
return true
|
||||
}
|
||||
|
||||
R.id.nav_stats -> {
|
||||
R.id.nav_stats -> {
|
||||
startActivity(Intent(this, StatsActivity::class.java))
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -7,9 +7,6 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
|||
import android.os.Bundle
|
||||
import androidx.annotation.XmlRes
|
||||
import androidx.preference.*
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.DispatchingAndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import dagger.android.support.AndroidSupportInjection
|
||||
import info.nightscout.androidaps.Config
|
||||
import info.nightscout.androidaps.R
|
||||
|
@ -58,9 +55,10 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper
|
|||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import javax.inject.Inject
|
||||
|
||||
class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeListener, HasAndroidInjector {
|
||||
class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeListener {
|
||||
|
||||
private var pluginId = -1
|
||||
private var filter = ""
|
||||
|
||||
@Inject lateinit var rxBus: RxBusWrapper
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
|
@ -102,11 +100,6 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
|||
@Inject lateinit var nsSettingStatus: NSSettingsStatus
|
||||
@Inject lateinit var openHumansUploader: OpenHumansUploader
|
||||
|
||||
// TODO why?
|
||||
@Inject lateinit var androidInjector: DispatchingAndroidInjector<Any>
|
||||
|
||||
override fun androidInjector(): AndroidInjector<Any> = androidInjector
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
AndroidSupportInjection.inject(this)
|
||||
super.onAttach(context)
|
||||
|
@ -115,11 +108,13 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
|||
override fun setArguments(args: Bundle?) {
|
||||
super.setArguments(args)
|
||||
pluginId = args?.getInt("id") ?: -1
|
||||
filter = args?.getString("filter") ?: ""
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putInt("id", pluginId)
|
||||
outState.putString("filter", filter)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
@ -150,6 +145,9 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
|||
if (bundle.containsKey("id")) {
|
||||
pluginId = bundle.getInt("id")
|
||||
}
|
||||
if (bundle.containsKey("filter")) {
|
||||
filter = bundle.getString("filter") ?: ""
|
||||
}
|
||||
}
|
||||
if (pluginId != -1) {
|
||||
addPreferencesFromResource(pluginId, rootKey)
|
||||
|
@ -175,7 +173,8 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
|||
addPreferencesFromResourceIfEnabled(localInsightPlugin, rootKey, config.PUMPDRIVERS)
|
||||
addPreferencesFromResourceIfEnabled(comboPlugin, rootKey, config.PUMPDRIVERS)
|
||||
addPreferencesFromResourceIfEnabled(medtronicPumpPlugin, rootKey, config.PUMPDRIVERS)
|
||||
addPreferencesFromResourceIfEnabled(virtualPumpPlugin, rootKey, !config.NSCLIENT)
|
||||
addPreferencesFromResource(R.xml.pref_pump, rootKey, config.PUMPDRIVERS)
|
||||
addPreferencesFromResourceIfEnabled(virtualPumpPlugin, rootKey)
|
||||
addPreferencesFromResourceIfEnabled(insulinOrefFreePeakPlugin, rootKey)
|
||||
addPreferencesFromResourceIfEnabled(nsClientPlugin, rootKey)
|
||||
addPreferencesFromResourceIfEnabled(tidepoolPlugin, rootKey)
|
||||
|
@ -190,6 +189,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
|||
}
|
||||
initSummary(preferenceScreen, pluginId != -1)
|
||||
preprocessPreferences()
|
||||
if (filter != "") updateFilterVisibility(filter, preferenceScreen)
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
|
@ -251,6 +251,10 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
|||
}
|
||||
}
|
||||
|
||||
private fun addPreferencesFromResource(@Suppress("SameParameterValue") @XmlRes preferencesResId: Int, key: String?, enabled: Boolean) {
|
||||
if (enabled) addPreferencesFromResource(preferencesResId, key)
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
private fun addPreferencesFromResource(@XmlRes preferencesResId: Int, key: String?) {
|
||||
val xmlRoot = preferenceManager.inflateFromResource(context,
|
||||
|
@ -283,6 +287,33 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateFilterVisibility(filter: String, p: Preference): Boolean {
|
||||
|
||||
var visible = false
|
||||
|
||||
if (p is PreferenceGroup) {
|
||||
for (i in 0 until p.preferenceCount) {
|
||||
visible = updateFilterVisibility(filter, p.getPreference(i)) || visible
|
||||
}
|
||||
if (visible && p is PreferenceCategory) {
|
||||
p.initialExpandedChildrenCount = Int.MAX_VALUE
|
||||
}
|
||||
} else {
|
||||
if (p.key != null) {
|
||||
visible = visible || p.key.contains(filter, true)
|
||||
}
|
||||
if (p.title != null) {
|
||||
visible = visible || p.title.contains(filter, true)
|
||||
}
|
||||
if (p.summary != null) {
|
||||
visible = visible || p.summary.contains(filter, true)
|
||||
}
|
||||
}
|
||||
|
||||
p.isVisible = visible
|
||||
return visible
|
||||
}
|
||||
|
||||
private fun updatePrefSummary(pref: Preference?) {
|
||||
if (pref is ListPreference) {
|
||||
pref.setSummary(pref.entry)
|
||||
|
@ -386,4 +417,9 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
|||
}
|
||||
return super.onPreferenceTreeClick(preference)
|
||||
}
|
||||
|
||||
fun setFilter(filter: String) {
|
||||
this.filter = filter
|
||||
updateFilterVisibility(filter, preferenceScreen)
|
||||
}
|
||||
}
|
|
@ -2,11 +2,14 @@ package info.nightscout.androidaps.activities
|
|||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceScreen
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.utils.locale.LocaleHelper
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import kotlinx.android.synthetic.main.activity_preferences.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompat.OnPreferenceStartScreenCallback {
|
||||
|
@ -14,18 +17,31 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa
|
|||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
|
||||
var preferenceId = 0
|
||||
var myPreferenceFragment: MyPreferenceFragment? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_single_fragment)
|
||||
setContentView(R.layout.activity_preferences)
|
||||
|
||||
pref_filter.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||
filterPreferences()
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable) {}
|
||||
})
|
||||
|
||||
title = resourceHelper.gs(R.string.nav_preferences)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
val myPreferenceFragment = MyPreferenceFragment()
|
||||
myPreferenceFragment = MyPreferenceFragment()
|
||||
preferenceId = intent.getIntExtra("id", -1)
|
||||
val args = Bundle()
|
||||
args.putInt("id", preferenceId)
|
||||
myPreferenceFragment.arguments = args
|
||||
supportFragmentManager.beginTransaction().replace(R.id.frame_layout, myPreferenceFragment).commit()
|
||||
args.putString("filter", pref_filter.text.toString())
|
||||
myPreferenceFragment?.arguments = args
|
||||
supportFragmentManager.beginTransaction().replace(R.id.frame_layout, myPreferenceFragment!!).commit()
|
||||
}
|
||||
|
||||
override fun onPreferenceStartScreen(caller: PreferenceFragmentCompat, pref: PreferenceScreen): Boolean {
|
||||
|
@ -44,4 +60,8 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa
|
|||
override fun attachBaseContext(newBase: Context) {
|
||||
super.attachBaseContext(LocaleHelper.wrap(newBase))
|
||||
}
|
||||
|
||||
private fun filterPreferences() {
|
||||
myPreferenceFragment?.setFilter(pref_filter.text.toString())
|
||||
}
|
||||
}
|
|
@ -9,6 +9,8 @@ import dagger.android.support.DaggerAppCompatActivity
|
|||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
|
||||
import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefs
|
||||
import info.nightscout.androidaps.plugins.general.maintenance.PrefsFileContract
|
||||
import info.nightscout.androidaps.utils.locale.LocaleHelper
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import javax.inject.Inject
|
||||
|
@ -16,9 +18,16 @@ import javax.inject.Inject
|
|||
class SingleFragmentActivity : DaggerAppCompatActivity() {
|
||||
@Inject lateinit var pluginStore: PluginStore
|
||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||
@Inject lateinit var importExportPrefs: ImportExportPrefs
|
||||
|
||||
private var plugin: PluginBase? = null
|
||||
|
||||
val callForPrefFile = registerForActivityResult(PrefsFileContract()) {
|
||||
it?.let {
|
||||
importExportPrefs.importSharedPreferences(this, it)
|
||||
}
|
||||
}
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_single_fragment)
|
||||
|
|
|
@ -417,6 +417,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
try {
|
||||
getDaoBgReadings().update(bgReading);
|
||||
openHumansUploader.enqueueBGReading(bgReading);
|
||||
aapsLogger.debug(LTag.DATABASE, "BG: Updating record from: "+ bgReading.toString());
|
||||
scheduleBgHistoryChange(bgReading.date); // trigger cache invalidation
|
||||
} catch (SQLException e) {
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import info.nightscout.androidaps.dana.di.DanaModule
|
|||
import info.nightscout.androidaps.danar.di.DanaRModule
|
||||
import info.nightscout.androidaps.danars.di.DanaRSModule
|
||||
import info.nightscout.androidaps.plugins.pump.common.dagger.RileyLinkModule
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dagger.OmnipodModule
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
|
@ -29,6 +30,7 @@ import javax.inject.Singleton
|
|||
WizardModule::class,
|
||||
RileyLinkModule::class,
|
||||
MedtronicModule::class,
|
||||
OmnipodModule::class,
|
||||
APSModule::class,
|
||||
PreferencesModule::class,
|
||||
OverviewModule::class,
|
||||
|
|
|
@ -26,4 +26,5 @@ abstract class CommandQueueModule {
|
|||
@ContributesAndroidInjector abstract fun commandTempBasalAbsoluteInjector(): CommandTempBasalAbsolute
|
||||
@ContributesAndroidInjector abstract fun commandTempBasalPercentInjector(): CommandTempBasalPercent
|
||||
@ContributesAndroidInjector abstract fun commandSetUserSettingsInjector(): CommandSetUserSettings
|
||||
@ContributesAndroidInjector abstract fun commandCustomCommandInjector(): CommandCustomCommand
|
||||
}
|
|
@ -36,6 +36,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyL
|
|||
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightFragment
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.RileyLinkStatusDeviceMedtronic
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.ui.OmnipodOverviewFragment
|
||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpFragment
|
||||
import info.nightscout.androidaps.plugins.source.BGSourceFragment
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsFragment
|
||||
|
@ -67,6 +68,7 @@ abstract class FragmentsModule {
|
|||
@ContributesAndroidInjector abstract fun contributesLoopFragment(): LoopFragment
|
||||
@ContributesAndroidInjector abstract fun contributesMaintenanceFragment(): MaintenanceFragment
|
||||
@ContributesAndroidInjector abstract fun contributesMedtronicFragment(): MedtronicFragment
|
||||
@ContributesAndroidInjector abstract fun contributesOmnipodFragment(): OmnipodOverviewFragment
|
||||
@ContributesAndroidInjector abstract fun contributesNSProfileFragment(): NSProfileFragment
|
||||
@ContributesAndroidInjector abstract fun contributesNSClientFragment(): NSClientFragment
|
||||
@ContributesAndroidInjector
|
||||
|
|
|
@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.general.persistentNotification.Persist
|
|||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
||||
import info.nightscout.androidaps.plugins.general.wear.WearPlugin
|
||||
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatusLinePlugin
|
||||
import info.nightscout.androidaps.plugins.insulin.InsulinLyumjevPlugin
|
||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin
|
||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefRapidActingPlugin
|
||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefUltraRapidActingPlugin
|
||||
|
@ -41,6 +42,7 @@ import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin
|
|||
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.mdi.MDIPlugin
|
||||
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.sensitivity.SensitivityAAPSPlugin
|
||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
|
||||
|
@ -82,6 +84,12 @@ abstract class PluginsModule {
|
|||
@IntKey(40)
|
||||
abstract fun bindInsulinOrefUltraRapidActingPlugin(plugin: InsulinOrefUltraRapidActingPlugin): PluginBase
|
||||
|
||||
@Binds
|
||||
@AllConfigs
|
||||
@IntoMap
|
||||
@IntKey(42)
|
||||
abstract fun bindInsulinLyumjevPlugin(plugin: InsulinLyumjevPlugin): PluginBase
|
||||
|
||||
@Binds
|
||||
@AllConfigs
|
||||
@IntoMap
|
||||
|
@ -148,6 +156,12 @@ abstract class PluginsModule {
|
|||
@IntKey(150)
|
||||
abstract fun bindMedtronicPumpPlugin(plugin: MedtronicPumpPlugin): PluginBase
|
||||
|
||||
@Binds
|
||||
@PumpDriver
|
||||
@IntoMap
|
||||
@IntKey(155)
|
||||
abstract fun bindOmnipodPumpPlugin(plugin: OmnipodPumpPlugin): PluginBase
|
||||
|
||||
@Binds
|
||||
@NotNSClient
|
||||
@IntoMap
|
||||
|
|
|
@ -10,6 +10,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.Riley
|
|||
import info.nightscout.androidaps.plugins.pump.insight.InsightAlertService
|
||||
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.omnipod.rileylink.service.RileyLinkOmnipodService
|
||||
import info.nightscout.androidaps.services.AlarmSoundService
|
||||
import info.nightscout.androidaps.services.DataService
|
||||
import info.nightscout.androidaps.services.LocationService
|
||||
|
@ -29,4 +30,5 @@ abstract class ServicesModule {
|
|||
@ContributesAndroidInjector abstract fun contributesInsightConnectionService(): InsightConnectionService
|
||||
@ContributesAndroidInjector abstract fun contributesRileyLinkService(): RileyLinkService
|
||||
@ContributesAndroidInjector abstract fun contributesRileyLinkMedtronicService(): RileyLinkMedtronicService
|
||||
@ContributesAndroidInjector abstract fun contributesRileyLinkOmnipodService(): RileyLinkOmnipodService
|
||||
}
|
|
@ -9,6 +9,7 @@ import info.nightscout.androidaps.skins.SkinButtonsOn
|
|||
import info.nightscout.androidaps.skins.SkinClassic
|
||||
import info.nightscout.androidaps.skins.SkinInterface
|
||||
import info.nightscout.androidaps.skins.SkinLargeDisplay
|
||||
import info.nightscout.androidaps.skins.SkinLowRes
|
||||
import javax.inject.Qualifier
|
||||
|
||||
@Module
|
||||
|
@ -32,6 +33,12 @@ open class SkinsModule {
|
|||
@IntKey(20)
|
||||
fun bindsSkinLargeDisplay(skinLargeDisplay: SkinLargeDisplay): SkinInterface = skinLargeDisplay
|
||||
|
||||
@Provides
|
||||
@Skin
|
||||
@IntoMap
|
||||
@IntKey(30)
|
||||
fun bindsSkinLowRes(skinLowRes: SkinLowRes): SkinInterface = skinLowRes
|
||||
|
||||
@Qualifier
|
||||
annotation class Skin
|
||||
}
|
|
@ -58,7 +58,7 @@ class CalibrationDialog : DialogFragmentWithDate() {
|
|||
val units = profileFunction.getUnits()
|
||||
val unitLabel = if (units == Constants.MMOL) resourceHelper.gs(R.string.mmol) else resourceHelper.gs(R.string.mgdl)
|
||||
val actions: LinkedList<String?> = LinkedList()
|
||||
val bg = overview_calibration_bg.value
|
||||
val bg = overview_calibration_bg?.value ?: return false
|
||||
actions.add(resourceHelper.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, bg) + " " + unitLabel)
|
||||
if (bg > 0) {
|
||||
activity?.let { activity ->
|
||||
|
|
|
@ -150,7 +150,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
|
||||
override fun submit(): Boolean {
|
||||
val carbs = overview_carbs_carbs.value.toInt()
|
||||
val carbs = overview_carbs_carbs?.value?.toInt() ?: return false
|
||||
val carbsAfterConstraints = constraintChecker.applyCarbsConstraints(Constraint(carbs)).value()
|
||||
val units = profileFunction.getUnits()
|
||||
val activityTTDuration = defaultValueHelper.determineActivityTTDuration()
|
||||
|
|
|
@ -122,7 +122,7 @@ class CareDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
}
|
||||
|
||||
val bg = Profile.fromMgdlToUnits(GlucoseStatus(injector).getGlucoseStatusData()?.glucose
|
||||
val bg = Profile.fromMgdlToUnits(GlucoseStatus(injector).glucoseStatusData?.glucose
|
||||
?: 0.0, profileFunction.getUnits())
|
||||
val bgTextWatcher: TextWatcher = object : TextWatcher {
|
||||
override fun afterTextChanged(s: Editable) {}
|
||||
|
|
|
@ -62,7 +62,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
|
||||
override fun submit(): Boolean {
|
||||
val insulin = SafeParse.stringToDouble(actions_extendedbolus_insulin.text)
|
||||
val insulin = SafeParse.stringToDouble(actions_extendedbolus_insulin?.text ?: return false)
|
||||
val durationInMinutes = actions_extendedbolus_duration.value.toInt()
|
||||
val actions: LinkedList<String> = LinkedList()
|
||||
val insulinAfterConstraint = constraintChecker.applyExtendedBolusConstraints(Constraint(insulin)).value()
|
||||
|
|
|
@ -85,7 +85,7 @@ class FillDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
|
||||
override fun submit(): Boolean {
|
||||
val insulin = SafeParse.stringToDouble(fill_insulinamount.text)
|
||||
val insulin = SafeParse.stringToDouble(fill_insulinamount?.text ?: return false)
|
||||
val actions: LinkedList<String?> = LinkedList()
|
||||
|
||||
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(insulin)).value()
|
||||
|
|
|
@ -129,7 +129,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun submit(): Boolean {
|
||||
val pumpDescription = activePlugin.activePump.pumpDescription
|
||||
val insulin = SafeParse.stringToDouble(overview_insulin_amount.text)
|
||||
val insulin = SafeParse.stringToDouble(overview_insulin_amount?.text ?: return false)
|
||||
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(insulin)).value()
|
||||
val actions: LinkedList<String?> = LinkedList()
|
||||
val units = profileFunction.getUnits()
|
||||
|
|
|
@ -52,7 +52,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
|||
overview_profileswitch_duration.setParams(savedInstanceState?.getDouble("overview_profileswitch_duration")
|
||||
?: 0.0, 0.0, Constants.MAX_PROFILE_SWITCH_DURATION, 10.0, DecimalFormat("0"), false, ok)
|
||||
overview_profileswitch_percentage.setParams(savedInstanceState?.getDouble("overview_profileswitch_percentage")
|
||||
?: 100.0, Constants.CPP_MIN_PERCENTAGE.toDouble(), Constants.CPP_MAX_PERCENTAGE.toDouble(), 1.0, DecimalFormat("0"), false, ok)
|
||||
?: 100.0, Constants.CPP_MIN_PERCENTAGE.toDouble(), Constants.CPP_MAX_PERCENTAGE.toDouble(), 5.0, DecimalFormat("0"), false, ok)
|
||||
overview_profileswitch_timeshift.setParams(savedInstanceState?.getDouble("overview_profileswitch_timeshift")
|
||||
?: 0.0, Constants.CPP_MIN_TIMESHIFT.toDouble(), Constants.CPP_MAX_TIMESHIFT.toDouble(), 1.0, DecimalFormat("0"), false, ok)
|
||||
|
||||
|
@ -91,7 +91,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
|||
?: return false
|
||||
|
||||
val actions: LinkedList<String> = LinkedList()
|
||||
val duration = overview_profileswitch_duration.value.toInt()
|
||||
val duration = overview_profileswitch_duration?.value?.toInt() ?: return false
|
||||
if (duration > 0)
|
||||
actions.add(resourceHelper.gs(R.string.duration) + ": " + resourceHelper.gs(R.string.format_mins, duration))
|
||||
val profile = overview_profileswitch_profile.selectedItem.toString()
|
||||
|
|
|
@ -84,7 +84,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
|||
override fun submit(): Boolean {
|
||||
var percent = 0
|
||||
var absolute = 0.0
|
||||
val durationInMinutes = actions_tempbasal_duration.value.toInt()
|
||||
val durationInMinutes = actions_tempbasal_duration?.value?.toInt() ?: return false
|
||||
val profile = profileFunction.getProfile() ?: return false
|
||||
val actions: LinkedList<String> = LinkedList()
|
||||
if (isPercentPump) {
|
||||
|
|
|
@ -116,7 +116,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun submit(): Boolean {
|
||||
val actions: LinkedList<String> = LinkedList()
|
||||
val reason = overview_temptarget_reason.selectedItem.toString()
|
||||
val reason = overview_temptarget_reason?.selectedItem?.toString() ?: return false
|
||||
val unitResId = if (profileFunction.getUnits() == Constants.MGDL) R.string.mgdl else R.string.mmol
|
||||
val target = overview_temptarget_temptarget.value
|
||||
val duration = overview_temptarget_duration.value.toInt()
|
||||
|
|
|
@ -94,7 +94,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun submit(): Boolean {
|
||||
val pumpDescription = activePlugin.activePump.pumpDescription
|
||||
val insulin = SafeParse.stringToDouble(overview_treatment_insulin.text)
|
||||
val insulin = SafeParse.stringToDouble(overview_treatment_insulin?.text ?: return false)
|
||||
val carbs = SafeParse.stringToInt(overview_treatment_carbs.text)
|
||||
val recordOnlyChecked = overview_treatment_record_only.isChecked
|
||||
val actions: LinkedList<String?> = LinkedList()
|
||||
|
|
|
@ -108,7 +108,7 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
|
||||
if (profileFunction.getUnits() == Constants.MGDL)
|
||||
treatments_wizard_bg_input.setParams(savedInstanceState?.getDouble("treatments_wizard_bg_input")
|
||||
?: 0.0, 0.0, 500.0, 1.0, DecimalFormat("0.0"), false, ok, textWatcher)
|
||||
?: 0.0, 0.0, 500.0, 1.0, DecimalFormat("0"), false, ok, textWatcher)
|
||||
else
|
||||
treatments_wizard_bg_input.setParams(savedInstanceState?.getDouble("treatments_wizard_bg_input")
|
||||
?: 0.0, 0.0, 30.0, 0.1, DecimalFormat("0.0"), false, ok, textWatcher)
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.view.ViewGroup
|
|||
import android.widget.LinearLayout
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.jjoe64.graphview.GraphView
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
|
@ -37,7 +38,6 @@ import io.reactivex.disposables.CompositeDisposable
|
|||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.android.synthetic.main.activity_historybrowse.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.*
|
||||
|
@ -168,7 +168,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
if (it.cause is EventCustomCalculationFinished) {
|
||||
updateGUI("EventAutosensCalculationFinished", bgOnly = false)
|
||||
}
|
||||
}) { fabricPrivacy::logException }
|
||||
}, fabricPrivacy::logException )
|
||||
)
|
||||
disposable.add(rxBus
|
||||
.toObservable(EventAutosensBgLoaded::class.java)
|
||||
|
@ -178,12 +178,12 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
if (it.cause is EventCustomCalculationFinished) {
|
||||
updateGUI("EventAutosensCalculationFinished", bgOnly = true)
|
||||
}
|
||||
}) { fabricPrivacy::logException }
|
||||
}, fabricPrivacy::logException )
|
||||
)
|
||||
disposable.add(rxBus
|
||||
.toObservable(EventIobCalculationProgress::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ overview_iobcalculationprogess?.text = it.progress }) { fabricPrivacy::logException }
|
||||
.subscribe({ overview_iobcalculationprogess?.text = it.progress }, fabricPrivacy::logException )
|
||||
)
|
||||
disposable.add(rxBus
|
||||
.toObservable(EventRefreshOverview::class.java)
|
||||
|
@ -193,7 +193,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
prepareGraphs()
|
||||
updateGUI("EventRefreshOverview", bgOnly = false)
|
||||
}
|
||||
}) { fabricPrivacy::logException }
|
||||
}, fabricPrivacy::logException )
|
||||
)
|
||||
if (start == 0L) {
|
||||
// set start of current day
|
||||
|
@ -256,7 +256,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
}
|
||||
|
||||
private fun runCalculation(from: String) {
|
||||
GlobalScope.launch(Dispatchers.Default) {
|
||||
lifecycleScope.launch(Dispatchers.Default) {
|
||||
treatmentsPluginHistory.initializeData(start - T.hours(8).msecs())
|
||||
val end = start + T.hours(rangeToDisplay.toLong()).msecs()
|
||||
iobCobCalculatorPluginHistory.stopCalculation(from)
|
||||
|
@ -273,7 +273,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
val lowLine = defaultValueHelper.determineLowLine()
|
||||
val highLine = defaultValueHelper.determineHighLine()
|
||||
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
lifecycleScope.launch(Dispatchers.Main) {
|
||||
historybrowse_noprofile?.visibility = (profile == null).toVisibility()
|
||||
profile ?: return@launch
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import info.nightscout.androidaps.interfaces.ProfileFunction
|
|||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentService
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
|
@ -27,8 +28,10 @@ class TreatmentsPluginHistory @Inject constructor(
|
|||
profileFunction: ProfileFunction,
|
||||
activePlugin: ActivePluginProvider,
|
||||
nsUpload: NSUpload,
|
||||
fabricPrivacy: FabricPrivacy, dateUtil: DateUtil
|
||||
) : TreatmentsPlugin(injector, aapsLogger, rxBus, resourceHelper, context, sp, profileFunction, activePlugin, nsUpload, fabricPrivacy, dateUtil) {
|
||||
fabricPrivacy: FabricPrivacy,
|
||||
dateUtil: DateUtil,
|
||||
uploadQueue: UploadQueue
|
||||
) : TreatmentsPlugin(injector, aapsLogger, rxBus, resourceHelper, context, sp, profileFunction, activePlugin, nsUpload, fabricPrivacy, dateUtil, uploadQueue) {
|
||||
|
||||
init {
|
||||
onStart()
|
||||
|
|
|
@ -22,6 +22,7 @@ import javax.inject.Singleton;
|
|||
import dagger.Lazy;
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainActivity;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
|
@ -55,10 +56,10 @@ import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui;
|
|||
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
|
@ -95,9 +96,8 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
|||
private final FabricPrivacy fabricPrivacy;
|
||||
private final NSUpload nsUpload;
|
||||
private final HardLimits hardLimits;
|
||||
private Notification notification;
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
private static final String CHANNEL_ID = "AndroidAPS-Openloop";
|
||||
|
||||
|
@ -126,6 +126,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
|||
AAPSLogger aapsLogger,
|
||||
RxBusWrapper rxBus,
|
||||
SP sp,
|
||||
Config config,
|
||||
ConstraintChecker constraintChecker,
|
||||
ResourceHelper resourceHelper,
|
||||
ProfileFunction profileFunction,
|
||||
|
@ -147,6 +148,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
|||
.pluginName(R.string.loop)
|
||||
.shortName(R.string.loop_shortname)
|
||||
.preferencesId(R.xml.pref_loop)
|
||||
.enableByDefault(config.getAPS())
|
||||
.description(R.string.description_loop),
|
||||
aapsLogger, resourceHelper, injector
|
||||
);
|
||||
|
@ -415,7 +417,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
|||
resultAfterConstraints.smb = 0;
|
||||
}
|
||||
|
||||
if (lastRun != null) {
|
||||
if (lastRun != null && lastRun.getConstraintsProcessed() != null) {
|
||||
prevCarbsreq = lastRun.getConstraintsProcessed().carbsReq;
|
||||
}
|
||||
|
||||
|
@ -551,6 +553,9 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
|||
rxBus.send(new EventLoopUpdateGui());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
lastRun.setTbrSetByPump(result);
|
||||
lastRun.setLastTBRRequest(lastRun.getLastAPSRun());
|
||||
}
|
||||
rxBus.send(new EventLoopUpdateGui());
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
|||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
public class DetermineBasalAdapterAMAJS {
|
||||
private HasAndroidInjector injector;
|
||||
private final HasAndroidInjector injector;
|
||||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject ConstraintChecker constraintChecker;
|
||||
@Inject SP sp;
|
||||
|
@ -48,7 +48,7 @@ public class DetermineBasalAdapterAMAJS {
|
|||
@Inject TreatmentsPlugin treatmentsPlugin;
|
||||
@Inject OpenHumansUploader openHumansUploader;
|
||||
|
||||
private ScriptReader mScriptReader;
|
||||
private final ScriptReader mScriptReader;
|
||||
|
||||
private JSONObject mProfile;
|
||||
private JSONObject mGlucoseStatus;
|
||||
|
|
|
@ -189,9 +189,9 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
|||
}
|
||||
|
||||
|
||||
if (!hardLimits.checkOnlyHardLimits(profile.getDia(), "dia", hardLimits.getMINDIA(), hardLimits.getMAXDIA()))
|
||||
if (!hardLimits.checkOnlyHardLimits(profile.getDia(), "dia", hardLimits.minDia(), hardLimits.maxDia()))
|
||||
return;
|
||||
if (!hardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", hardLimits.getMINIC(), hardLimits.getMAXIC()))
|
||||
if (!hardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", hardLimits.minIC(), hardLimits.maxIC()))
|
||||
return;
|
||||
if (!hardLimits.checkOnlyHardLimits(profile.getIsfMgdl(), "sens", hardLimits.getMINISF(), hardLimits.getMAXISF()))
|
||||
return;
|
||||
|
|
|
@ -55,7 +55,7 @@ public class DetermineBasalAdapterSMBJS {
|
|||
@Inject OpenHumansUploader openHumansUploader;
|
||||
|
||||
|
||||
private ScriptReader mScriptReader;
|
||||
private final ScriptReader mScriptReader;
|
||||
private JSONObject mProfile;
|
||||
private JSONObject mGlucoseStatus;
|
||||
private JSONArray mIobData;
|
||||
|
@ -65,6 +65,7 @@ public class DetermineBasalAdapterSMBJS {
|
|||
private boolean mMicrobolusAllowed;
|
||||
private boolean mSMBAlwaysAllowed;
|
||||
private long mCurrentTime;
|
||||
private boolean mIsSaveCgmSource;
|
||||
|
||||
private String storedCurrentTemp = null;
|
||||
private String storedIobData = null;
|
||||
|
@ -108,6 +109,7 @@ public class DetermineBasalAdapterSMBJS {
|
|||
aapsLogger.debug(LTag.APS, "MicroBolusAllowed: " + (storedMicroBolusAllowed = "" + mMicrobolusAllowed));
|
||||
aapsLogger.debug(LTag.APS, "SMBAlwaysAllowed: " + (storedSMBAlwaysAllowed = "" + mSMBAlwaysAllowed));
|
||||
aapsLogger.debug(LTag.APS, "CurrentTime: " + (storedCurrentTime = "" + mCurrentTime));
|
||||
aapsLogger.debug(LTag.APS, "isSaveCgmSource: " + mIsSaveCgmSource);
|
||||
|
||||
|
||||
DetermineBasalResultSMB determineBasalResultSMB = null;
|
||||
|
@ -237,7 +239,8 @@ public class DetermineBasalAdapterSMBJS {
|
|||
boolean tempTargetSet,
|
||||
boolean microBolusAllowed,
|
||||
boolean uamAllowed,
|
||||
boolean advancedFiltering
|
||||
boolean advancedFiltering,
|
||||
boolean isSaveCgmSource
|
||||
) throws JSONException {
|
||||
|
||||
String units = profile.getUnits();
|
||||
|
@ -282,7 +285,7 @@ public class DetermineBasalAdapterSMBJS {
|
|||
mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable);
|
||||
|
||||
boolean smbEnabled = sp.getBoolean(resourceHelper.gs(R.string.key_use_smb), false);
|
||||
mProfile.put("SMBInterval", sp.getInt("key_smbinterval", SMBDefaults.SMBInterval));
|
||||
mProfile.put("SMBInterval", sp.getInt(R.string.key_smbinterval, SMBDefaults.SMBInterval));
|
||||
mProfile.put("enableSMB_with_COB", smbEnabled && sp.getBoolean(R.string.key_enableSMB_with_COB, false));
|
||||
mProfile.put("enableSMB_with_temptarget", smbEnabled && sp.getBoolean(R.string.key_enableSMB_with_temptarget, false));
|
||||
mProfile.put("allowSMB_with_high_temptarget", smbEnabled && sp.getBoolean(R.string.key_allowSMB_with_high_temptarget, false));
|
||||
|
@ -354,6 +357,7 @@ public class DetermineBasalAdapterSMBJS {
|
|||
|
||||
mCurrentTime = now;
|
||||
|
||||
mIsSaveCgmSource = isSaveCgmSource;
|
||||
}
|
||||
|
||||
private Object makeParam(JSONObject jsonObject, Context rhino, Scriptable scope) {
|
||||
|
|
|
@ -220,9 +220,9 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
|||
}
|
||||
|
||||
|
||||
if (!hardLimits.checkOnlyHardLimits(profile.getDia(), "dia", hardLimits.getMINDIA(), hardLimits.getMAXDIA()))
|
||||
if (!hardLimits.checkOnlyHardLimits(profile.getDia(), "dia", hardLimits.minDia(), hardLimits.maxDia()))
|
||||
return;
|
||||
if (!hardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", hardLimits.getMINIC(), hardLimits.getMAXIC()))
|
||||
if (!hardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", hardLimits.minIC(), hardLimits.maxIC()))
|
||||
return;
|
||||
if (!hardLimits.checkOnlyHardLimits(profile.getIsfMgdl(), "sens", hardLimits.getMINISF(), hardLimits.getMAXISF()))
|
||||
return;
|
||||
|
@ -270,7 +270,8 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
|||
isTempTarget,
|
||||
smbAllowed.value(),
|
||||
uam.value(),
|
||||
advancedFiltering.value()
|
||||
advancedFiltering.value(),
|
||||
activePlugin.getActiveBgSource().getClass().getSimpleName().equals("DexcomPlugin")
|
||||
);
|
||||
} catch (JSONException e) {
|
||||
fabricPrivacy.logException(e);
|
||||
|
|
|
@ -5,12 +5,9 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.CheckBox
|
||||
import android.widget.ImageButton
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.RadioButton
|
||||
import android.widget.TextView
|
||||
import android.widget.*
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.androidaps.Config
|
||||
import info.nightscout.androidaps.R
|
||||
|
@ -129,6 +126,7 @@ class ConfigBuilderFragment : DaggerFragment() {
|
|||
val baseView: LinearLayout = fragment.layoutInflater.inflate(R.layout.configbuilder_single_plugin, null) as LinearLayout
|
||||
private val enabledExclusive: RadioButton
|
||||
private val enabledInclusive: CheckBox
|
||||
private val pluginIcon: ImageView
|
||||
private val pluginName: TextView
|
||||
private val pluginDescription: TextView
|
||||
private val pluginPreferences: ImageButton
|
||||
|
@ -137,6 +135,7 @@ class ConfigBuilderFragment : DaggerFragment() {
|
|||
init {
|
||||
enabledExclusive = baseView.findViewById(R.id.plugin_enabled_exclusive)
|
||||
enabledInclusive = baseView.findViewById(R.id.plugin_enabled_inclusive)
|
||||
pluginIcon = baseView.findViewById(R.id.plugin_icon)
|
||||
pluginName = baseView.findViewById(R.id.plugin_name)
|
||||
pluginDescription = baseView.findViewById(R.id.plugin_description)
|
||||
pluginPreferences = baseView.findViewById(R.id.plugin_preferences)
|
||||
|
@ -175,6 +174,12 @@ class ConfigBuilderFragment : DaggerFragment() {
|
|||
enabledInclusive.isChecked = plugin.isEnabled(pluginType)
|
||||
enabledInclusive.isEnabled = !plugin.pluginDescription.alwaysEnabled
|
||||
enabledExclusive.isEnabled = !plugin.pluginDescription.alwaysEnabled
|
||||
if(plugin.menuIcon != -1) {
|
||||
pluginIcon.visibility = View.VISIBLE
|
||||
pluginIcon.setImageDrawable(context?.let { ContextCompat.getDrawable(it, plugin.menuIcon) })
|
||||
} else {
|
||||
pluginIcon.visibility = View.GONE
|
||||
}
|
||||
pluginName.text = plugin.name
|
||||
if (plugin.description == null)
|
||||
pluginDescription.visibility = View.GONE
|
||||
|
|
|
@ -46,17 +46,17 @@ class ConfigBuilderPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
private fun setAlwaysEnabledPluginsEnabled() {
|
||||
for (plugin in activePlugin.pluginsList) {
|
||||
for (plugin in activePlugin.getPluginsList()) {
|
||||
if (plugin.pluginDescription.alwaysEnabled) plugin.setPluginEnabled(plugin.getType(), true)
|
||||
}
|
||||
storeSettings("setAlwaysEnabledPluginsEnabled")
|
||||
}
|
||||
|
||||
override fun storeSettings(from: String) {
|
||||
activePlugin.pluginsList
|
||||
activePlugin.getPluginsList()
|
||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Storing settings from: $from")
|
||||
activePlugin.verifySelectionInCategories()
|
||||
for (p in activePlugin.pluginsList) {
|
||||
for (p in activePlugin.getPluginsList()) {
|
||||
val type = p.getType()
|
||||
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.alwaysVisible) continue
|
||||
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.neverVisible) continue
|
||||
|
@ -82,7 +82,7 @@ class ConfigBuilderPlugin @Inject constructor(
|
|||
|
||||
private fun loadSettings() {
|
||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Loading stored settings")
|
||||
for (p in activePlugin.pluginsList) {
|
||||
for (p in activePlugin.getPluginsList()) {
|
||||
val type = p.getType()
|
||||
loadPref(p, type, true)
|
||||
if (p.getType() == PluginType.PUMP) {
|
||||
|
@ -110,7 +110,7 @@ class ConfigBuilderPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
fun logPluginStatus() {
|
||||
for (p in activePlugin.pluginsList) {
|
||||
for (p in activePlugin.getPluginsList()) {
|
||||
aapsLogger.debug(LTag.CONFIGBUILDER, p.name + ":" +
|
||||
(if (p.isEnabled(PluginType.GENERAL)) " GENERAL" else "") +
|
||||
(if (p.isEnabled(PluginType.TREATMENT)) " TREATMENT" else "") +
|
||||
|
@ -147,7 +147,7 @@ class ConfigBuilderPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun performPluginSwitch(changedPlugin: PluginBase, enabled: Boolean, type: PluginType) {
|
||||
override fun performPluginSwitch(changedPlugin: PluginBase, enabled: Boolean, type: PluginType) {
|
||||
changedPlugin.setPluginEnabled(type, enabled)
|
||||
changedPlugin.setFragmentVisible(type, enabled)
|
||||
processOnEnabledCategoryChanged(changedPlugin, type)
|
||||
|
|
|
@ -15,13 +15,13 @@ class PluginStore @Inject constructor(
|
|||
|
||||
lateinit var plugins: List<@JvmSuppressWildcards PluginBase>
|
||||
|
||||
private var activeBgSource: BgSourceInterface? = null
|
||||
private var activePump: PumpInterface? = null
|
||||
private var activeBgSourceStore: BgSourceInterface? = null
|
||||
private var activePumpStore: PumpInterface? = null
|
||||
private var activeProfile: ProfileInterface? = null
|
||||
private var activeAPS: APSInterface? = null
|
||||
private var activeInsulin: InsulinInterface? = null
|
||||
private var activeSensitivity: SensitivityInterface? = null
|
||||
private var activeTreatments: TreatmentsInterface? = null
|
||||
private var activeAPSStore: APSInterface? = null
|
||||
private var activeInsulinStore: InsulinInterface? = null
|
||||
private var activeSensitivityStore: SensitivityInterface? = null
|
||||
private var activeTreatmentsStore: TreatmentsInterface? = null
|
||||
|
||||
fun loadDefaults() {
|
||||
verifySelectionInCategories()
|
||||
|
@ -71,34 +71,34 @@ class PluginStore @Inject constructor(
|
|||
// PluginType.APS
|
||||
if (!config.NSCLIENT && !config.PUMPCONTROL) {
|
||||
pluginsInCategory = getSpecificPluginsList(PluginType.APS)
|
||||
activeAPS = getTheOneEnabledInArray(pluginsInCategory, PluginType.APS) as APSInterface?
|
||||
if (activeAPS == null) {
|
||||
activeAPS = getDefaultPlugin(PluginType.APS) as APSInterface
|
||||
(activeAPS as PluginBase).setPluginEnabled(PluginType.APS, true)
|
||||
activeAPSStore = getTheOneEnabledInArray(pluginsInCategory, PluginType.APS) as APSInterface?
|
||||
if (activeAPSStore == null) {
|
||||
activeAPSStore = getDefaultPlugin(PluginType.APS) as APSInterface
|
||||
(activeAPSStore as PluginBase).setPluginEnabled(PluginType.APS, true)
|
||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting APSInterface")
|
||||
}
|
||||
setFragmentVisiblities((activeAPS as PluginBase).name, pluginsInCategory, PluginType.APS)
|
||||
setFragmentVisiblities((activeAPSStore as PluginBase).name, pluginsInCategory, PluginType.APS)
|
||||
}
|
||||
|
||||
// PluginType.INSULIN
|
||||
pluginsInCategory = getSpecificPluginsList(PluginType.INSULIN)
|
||||
activeInsulin = getTheOneEnabledInArray(pluginsInCategory, PluginType.INSULIN) as InsulinInterface?
|
||||
if (activeInsulin == null) {
|
||||
activeInsulin = getDefaultPlugin(PluginType.INSULIN) as InsulinInterface
|
||||
(activeInsulin as PluginBase).setPluginEnabled(PluginType.INSULIN, true)
|
||||
activeInsulinStore = getTheOneEnabledInArray(pluginsInCategory, PluginType.INSULIN) as InsulinInterface?
|
||||
if (activeInsulinStore == null) {
|
||||
activeInsulinStore = getDefaultPlugin(PluginType.INSULIN) as InsulinInterface
|
||||
(activeInsulinStore as PluginBase).setPluginEnabled(PluginType.INSULIN, true)
|
||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting InsulinInterface")
|
||||
}
|
||||
setFragmentVisiblities((activeInsulin as PluginBase).name, pluginsInCategory, PluginType.INSULIN)
|
||||
setFragmentVisiblities((activeInsulinStore as PluginBase).name, pluginsInCategory, PluginType.INSULIN)
|
||||
|
||||
// PluginType.SENSITIVITY
|
||||
pluginsInCategory = getSpecificPluginsList(PluginType.SENSITIVITY)
|
||||
activeSensitivity = getTheOneEnabledInArray(pluginsInCategory, PluginType.SENSITIVITY) as SensitivityInterface?
|
||||
if (activeSensitivity == null) {
|
||||
activeSensitivity = getDefaultPlugin(PluginType.SENSITIVITY) as SensitivityInterface
|
||||
(activeSensitivity as PluginBase).setPluginEnabled(PluginType.SENSITIVITY, true)
|
||||
activeSensitivityStore = getTheOneEnabledInArray(pluginsInCategory, PluginType.SENSITIVITY) as SensitivityInterface?
|
||||
if (activeSensitivityStore == null) {
|
||||
activeSensitivityStore = getDefaultPlugin(PluginType.SENSITIVITY) as SensitivityInterface
|
||||
(activeSensitivityStore as PluginBase).setPluginEnabled(PluginType.SENSITIVITY, true)
|
||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting SensitivityInterface")
|
||||
}
|
||||
setFragmentVisiblities((activeSensitivity as PluginBase).name, pluginsInCategory, PluginType.SENSITIVITY)
|
||||
setFragmentVisiblities((activeSensitivityStore as PluginBase).name, pluginsInCategory, PluginType.SENSITIVITY)
|
||||
|
||||
// PluginType.PROFILE
|
||||
pluginsInCategory = getSpecificPluginsList(PluginType.PROFILE)
|
||||
|
@ -112,33 +112,33 @@ class PluginStore @Inject constructor(
|
|||
|
||||
// PluginType.BGSOURCE
|
||||
pluginsInCategory = getSpecificPluginsList(PluginType.BGSOURCE)
|
||||
activeBgSource = getTheOneEnabledInArray(pluginsInCategory, PluginType.BGSOURCE) as BgSourceInterface?
|
||||
if (activeBgSource == null) {
|
||||
activeBgSource = getDefaultPlugin(PluginType.BGSOURCE) as BgSourceInterface
|
||||
(activeBgSource as PluginBase).setPluginEnabled(PluginType.BGSOURCE, true)
|
||||
activeBgSourceStore = getTheOneEnabledInArray(pluginsInCategory, PluginType.BGSOURCE) as BgSourceInterface?
|
||||
if (activeBgSourceStore == null) {
|
||||
activeBgSourceStore = getDefaultPlugin(PluginType.BGSOURCE) as BgSourceInterface
|
||||
(activeBgSourceStore as PluginBase).setPluginEnabled(PluginType.BGSOURCE, true)
|
||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting BgInterface")
|
||||
}
|
||||
setFragmentVisiblities((activeBgSource as PluginBase).name, pluginsInCategory, PluginType.PUMP)
|
||||
setFragmentVisiblities((activeBgSourceStore as PluginBase).name, pluginsInCategory, PluginType.PUMP)
|
||||
|
||||
// PluginType.PUMP
|
||||
pluginsInCategory = getSpecificPluginsList(PluginType.PUMP)
|
||||
activePump = getTheOneEnabledInArray(pluginsInCategory, PluginType.PUMP) as PumpInterface?
|
||||
if (activePump == null) {
|
||||
activePump = getDefaultPlugin(PluginType.PUMP) as PumpInterface
|
||||
(activePump as PluginBase).setPluginEnabled(PluginType.PUMP, true)
|
||||
activePumpStore = getTheOneEnabledInArray(pluginsInCategory, PluginType.PUMP) as PumpInterface?
|
||||
if (activePumpStore == null) {
|
||||
activePumpStore = getDefaultPlugin(PluginType.PUMP) as PumpInterface
|
||||
(activePumpStore as PluginBase).setPluginEnabled(PluginType.PUMP, true)
|
||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting PumpInterface")
|
||||
}
|
||||
setFragmentVisiblities((activePump as PluginBase).name, pluginsInCategory, PluginType.PUMP)
|
||||
setFragmentVisiblities((activePumpStore as PluginBase).name, pluginsInCategory, PluginType.PUMP)
|
||||
|
||||
// PluginType.TREATMENT
|
||||
pluginsInCategory = getSpecificPluginsList(PluginType.TREATMENT)
|
||||
activeTreatments = getTheOneEnabledInArray(pluginsInCategory, PluginType.TREATMENT) as TreatmentsInterface?
|
||||
if (activeTreatments == null) {
|
||||
activeTreatments = getDefaultPlugin(PluginType.TREATMENT) as TreatmentsInterface
|
||||
(activeTreatments as PluginBase).setPluginEnabled(PluginType.TREATMENT, true)
|
||||
activeTreatmentsStore = getTheOneEnabledInArray(pluginsInCategory, PluginType.TREATMENT) as TreatmentsInterface?
|
||||
if (activeTreatmentsStore == null) {
|
||||
activeTreatmentsStore = getDefaultPlugin(PluginType.TREATMENT) as TreatmentsInterface
|
||||
(activeTreatmentsStore as PluginBase).setPluginEnabled(PluginType.TREATMENT, true)
|
||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting PumpInterface")
|
||||
}
|
||||
setFragmentVisiblities((activeTreatments as PluginBase).name, pluginsInCategory, PluginType.TREATMENT)
|
||||
setFragmentVisiblities((activeTreatmentsStore as PluginBase).name, pluginsInCategory, PluginType.TREATMENT)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -203,27 +203,31 @@ class PluginStore @Inject constructor(
|
|||
|
||||
// ***** Interface *****
|
||||
|
||||
override fun getActiveBgSource(): BgSourceInterface {
|
||||
return activeBgSource ?: checkNotNull(activeBgSource) { "No bg source selected" }
|
||||
}
|
||||
override val activeBgSource: BgSourceInterface
|
||||
get() = activeBgSourceStore ?: checkNotNull(activeBgSourceStore) { "No bg source selected" }
|
||||
|
||||
override fun getActiveProfileInterface(): ProfileInterface =
|
||||
activeProfile ?: checkNotNull(activeProfile) { "No profile selected" }
|
||||
override val activeProfileInterface: ProfileInterface
|
||||
get() = activeProfile ?: checkNotNull(activeProfile) { "No profile selected" }
|
||||
|
||||
override fun getActiveInsulin(): InsulinInterface =
|
||||
activeInsulin ?: checkNotNull(activeInsulin) { "No insulin selected" }
|
||||
override val activeInsulin: InsulinInterface
|
||||
get() = activeInsulinStore ?: checkNotNull(activeInsulinStore) { "No insulin selected" }
|
||||
|
||||
override fun getActiveAPS(): APSInterface =
|
||||
activeAPS ?: checkNotNull(activeAPS) { "No APS selected" }
|
||||
override val activeAPS: APSInterface
|
||||
get() = activeAPSStore ?: checkNotNull(activeAPSStore) { "No APS selected" }
|
||||
|
||||
override fun getActivePump(): PumpInterface =
|
||||
activePump ?: checkNotNull(activePump) { "No pump selected" }
|
||||
override val activePump: PumpInterface
|
||||
get() = activePumpStore ?: checkNotNull(activePumpStore) { "No pump selected" }
|
||||
|
||||
override fun getActiveSensitivity(): SensitivityInterface =
|
||||
activeSensitivity ?: checkNotNull(activeSensitivity) { "No sensitivity selected" }
|
||||
override val activeSensitivity: SensitivityInterface
|
||||
get() = activeSensitivityStore
|
||||
?: checkNotNull(activeSensitivityStore) { "No sensitivity selected" }
|
||||
|
||||
override fun getActiveTreatments(): TreatmentsInterface =
|
||||
activeTreatments ?: checkNotNull(activeTreatments) { "No treatments selected" }
|
||||
override val activeTreatments: TreatmentsInterface
|
||||
get() = activeTreatmentsStore
|
||||
?: checkNotNull(activeTreatmentsStore) { "No treatments selected" }
|
||||
|
||||
override val activeOverview: OverviewInterface
|
||||
get() = getSpecificPluginsListByInterface(OverviewInterface::class.java).first() as OverviewInterface
|
||||
|
||||
override fun getPluginsList(): ArrayList<PluginBase> = ArrayList(plugins)
|
||||
|
||||
|
|
|
@ -2,5 +2,4 @@ package info.nightscout.androidaps.plugins.configBuilder.events
|
|||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui
|
||||
|
||||
class EventConfigBuilderUpdateGui : EventUpdateGui() {
|
||||
}
|
||||
class EventConfigBuilderUpdateGui : EventUpdateGui()
|
|
@ -1,6 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.constraints.objectives
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.google.common.base.Charsets
|
||||
import com.google.common.hash.Hashing
|
||||
import dagger.android.HasAndroidInjector
|
||||
|
@ -116,7 +116,7 @@ class ObjectivesPlugin @Inject constructor(
|
|||
sp.putBoolean(R.string.key_objectiveusescale, false)
|
||||
}
|
||||
|
||||
fun completeObjectives(activity: Activity, request: String) {
|
||||
fun completeObjectives(activity: FragmentActivity, request: String) {
|
||||
val requestCode = sp.getString(R.string.key_objectives_request_code, "")
|
||||
var url = sp.getString(R.string.key_nsclientinternal_url, "").toLowerCase(Locale.getDefault())
|
||||
if (!url.endsWith("/")) url = "$url/"
|
||||
|
@ -145,7 +145,7 @@ class ObjectivesPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun allPriorAccomplished(position: Int) : Boolean {
|
||||
fun allPriorAccomplished(position: Int): Boolean {
|
||||
var accomplished = true
|
||||
for (i in 0 until position) {
|
||||
accomplished = accomplished && objectives[i].isAccomplished
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.widget.CheckBox;
|
|||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -25,9 +26,9 @@ public abstract class Objective {
|
|||
@Inject public SP sp;
|
||||
@Inject public ResourceHelper resourceHelper;
|
||||
|
||||
private String spName;
|
||||
@StringRes private int objective;
|
||||
@StringRes private int gate;
|
||||
private final String spName;
|
||||
@StringRes private final int objective;
|
||||
@StringRes private final int gate;
|
||||
private long startedOn;
|
||||
private long accomplishedOn;
|
||||
List<Task> tasks = new ArrayList<>();
|
||||
|
@ -110,12 +111,12 @@ public abstract class Objective {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void specialAction(Activity activity, String input) {
|
||||
public void specialAction(FragmentActivity activity, String input) {
|
||||
}
|
||||
|
||||
public abstract class Task {
|
||||
@StringRes
|
||||
private int task;
|
||||
private final int task;
|
||||
private Objective objective;
|
||||
ArrayList<Hint> hints = new ArrayList<>();
|
||||
|
||||
|
@ -137,8 +138,6 @@ public abstract class Objective {
|
|||
return isCompleted();
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public String getProgress() {
|
||||
return resourceHelper.gs(isCompleted() ? R.string.completed_well_done : R.string.not_completed_yet);
|
||||
}
|
||||
|
@ -159,7 +158,7 @@ public abstract class Objective {
|
|||
|
||||
public class MinimumDurationTask extends Task {
|
||||
|
||||
private long minimumDuration;
|
||||
private final long minimumDuration;
|
||||
|
||||
MinimumDurationTask(long minimumDuration) {
|
||||
super(R.string.time_elapsed);
|
||||
|
@ -196,7 +195,7 @@ public abstract class Objective {
|
|||
@StringRes
|
||||
int question;
|
||||
ArrayList<Option> options = new ArrayList<>();
|
||||
private String spIdentifier;
|
||||
private final String spIdentifier;
|
||||
private boolean answered;
|
||||
private long disabledTo;
|
||||
|
||||
|
@ -273,8 +272,7 @@ public abstract class Objective {
|
|||
public boolean evaluate() {
|
||||
boolean selection = cb.isChecked();
|
||||
if (selection && isCorrect) return true;
|
||||
if (!selection && !isCorrect) return true;
|
||||
return false;
|
||||
return !selection && !isCorrect;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class Objective0 extends Objective {
|
|||
tasks.add(new Task(R.string.virtualpump_uploadstatus_title) {
|
||||
@Override
|
||||
public boolean isCompleted() {
|
||||
return sp.getBoolean("virtualpump_uploadstatus", false);
|
||||
return sp.getBoolean(R.string.key_virtualpump_uploadstatus, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,9 +78,7 @@ public class Objective0 extends Objective {
|
|||
@Override
|
||||
public boolean isCompleted() {
|
||||
APSInterface usedAPS = activePlugin.getActiveAPS();
|
||||
if (((PluginBase) usedAPS).isEnabled(PluginType.APS))
|
||||
return true;
|
||||
return false;
|
||||
return ((PluginBase) usedAPS).isEnabled(PluginType.APS);
|
||||
}
|
||||
});
|
||||
tasks.add(new Task(R.string.activate_profile) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.constraints.objectives.objectives;
|
||||
|
||||
import android.app.Activity;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -10,6 +10,7 @@ import dagger.android.HasAndroidInjector;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.services.NSClientService;
|
||||
import info.nightscout.androidaps.utils.T;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
@ -50,11 +51,11 @@ public class Objective3 extends Objective {
|
|||
|
||||
@Override
|
||||
public boolean specialActionEnabled() {
|
||||
return nsClientPlugin.nsClientService.isConnected && nsClientPlugin.nsClientService.hasWriteAuth;
|
||||
return NSClientService.isConnected && NSClientService.hasWriteAuth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void specialAction(Activity activity, String input) {
|
||||
public void specialAction(FragmentActivity activity, String input) {
|
||||
objectivesPlugin.completeObjectives(activity, input);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,12 +36,12 @@ class PhoneCheckerPlugin @Inject constructor(
|
|||
|
||||
private fun isDevModeEnabled(): Boolean {
|
||||
return android.provider.Settings.Secure.getInt(context.contentResolver,
|
||||
android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
|
||||
android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
phoneRooted = RootBeer(context).isRooted()
|
||||
phoneRooted = RootBeer(context).isRooted
|
||||
devMode = isDevModeEnabled()
|
||||
}
|
||||
}
|
|
@ -37,17 +37,17 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
|||
@Singleton
|
||||
public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||
|
||||
private SP sp;
|
||||
private RxBusWrapper rxBus;
|
||||
private ConstraintChecker constraintChecker;
|
||||
private OpenAPSAMAPlugin openAPSAMAPlugin;
|
||||
private OpenAPSSMBPlugin openAPSSMBPlugin;
|
||||
private SensitivityOref1Plugin sensitivityOref1Plugin;
|
||||
private ActivePluginProvider activePlugin;
|
||||
private HardLimits hardLimits;
|
||||
private BuildHelper buildHelper;
|
||||
private TreatmentsPlugin treatmentsPlugin;
|
||||
private Config config;
|
||||
private final SP sp;
|
||||
private final RxBusWrapper rxBus;
|
||||
private final ConstraintChecker constraintChecker;
|
||||
private final OpenAPSAMAPlugin openAPSAMAPlugin;
|
||||
private final OpenAPSSMBPlugin openAPSSMBPlugin;
|
||||
private final SensitivityOref1Plugin sensitivityOref1Plugin;
|
||||
private final ActivePluginProvider activePlugin;
|
||||
private final HardLimits hardLimits;
|
||||
private final BuildHelper buildHelper;
|
||||
private final TreatmentsPlugin treatmentsPlugin;
|
||||
private final Config config;
|
||||
|
||||
@Inject
|
||||
public SafetyPlugin(
|
||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.general.actions
|
|||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -9,6 +10,7 @@ import android.widget.LinearLayout
|
|||
import androidx.core.content.ContextCompat
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.androidaps.Config
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
|
@ -24,6 +26,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
|||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
|
||||
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.skins.SkinProvider
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||
|
@ -54,16 +57,30 @@ class ActionsFragment : DaggerFragment() {
|
|||
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||
@Inject lateinit var buildHelper: BuildHelper
|
||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||
@Inject lateinit var skinProvider: SkinProvider
|
||||
@Inject lateinit var config: Config
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
private val pumpCustomActions = HashMap<String, CustomAction>()
|
||||
private val pumpCustomButtons = ArrayList<SingleClickButton>()
|
||||
private var smallWidth = false
|
||||
private var smallHeight = false
|
||||
private lateinit var dm: DisplayMetrics
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.actions_fragment, container, false)
|
||||
//check screen width
|
||||
dm = DisplayMetrics()
|
||||
activity?.windowManager?.defaultDisplay?.getMetrics(dm)
|
||||
|
||||
val screenWidth = dm.widthPixels
|
||||
val screenHeight = dm.heightPixels
|
||||
smallWidth = screenWidth <= Constants.SMALL_WIDTH
|
||||
smallHeight = screenHeight <= Constants.SMALL_HEIGHT
|
||||
val landscape = screenHeight < screenWidth
|
||||
|
||||
return inflater.inflate(skinProvider.activeSkin().actionsLayout(landscape, smallWidth), container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
@ -233,26 +250,36 @@ class ActionsFragment : DaggerFragment() {
|
|||
actions_canceltempbasal?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
val activeBgSource = activePlugin.activeBgSource
|
||||
actions_historybrowser.visibility = (profile != null).toVisibility()
|
||||
actions_fill?.visibility = (pump.pumpDescription.isRefillingCapable && pump.isInitialized && !pump.isSuspended).toVisibility()
|
||||
actions_pumpbatterychange?.visibility = pump.pumpDescription.isBatteryReplaceable.toVisibility()
|
||||
actions_temptarget?.visibility = (profile != null && config.APS).toVisibility()
|
||||
actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
|
||||
|
||||
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null)
|
||||
if (!config.NSCLIENT) {
|
||||
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, careportal_sensorlevel, careportal_pbage, careportal_batterylevel)
|
||||
careportal_senslevellabel?.text = if (activeBgSource.sensorBatteryLevel == -1) "" else resourceHelper.gs(R.string.careportal_level_label)
|
||||
} else {
|
||||
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, null, careportal_pbage, null)
|
||||
careportal_senslevellabel?.text = ""
|
||||
careportal_inslevellabel?.text = ""
|
||||
careportal_pblevellabel?.text = ""
|
||||
}
|
||||
checkPumpCustomActions()
|
||||
|
||||
}
|
||||
|
||||
private fun checkPumpCustomActions() {
|
||||
val activePump = activePlugin.activePump
|
||||
val customActions = activePump.customActions ?: return
|
||||
val currentContext = context ?: return
|
||||
removePumpCustomActions()
|
||||
|
||||
for (customAction in customActions) {
|
||||
if (!customAction.isEnabled) continue
|
||||
|
||||
val btn = SingleClickButton(context, null, android.R.attr.buttonStyle)
|
||||
val btn = SingleClickButton(currentContext, null, android.R.attr.buttonStyle)
|
||||
btn.text = resourceHelper.gs(customAction.name)
|
||||
|
||||
val layoutParams = LinearLayout.LayoutParams(
|
||||
|
|
|
@ -192,6 +192,17 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener {
|
|||
}
|
||||
v.onTouchEvent(motionEvent)
|
||||
}
|
||||
// remove event
|
||||
holder.iconTrash.setOnClickListener {
|
||||
showConfirmation(requireContext(), resourceHelper.gs(R.string.removerecord) + " " + automationPlugin.automationEvents[position].title,
|
||||
Runnable {
|
||||
automationPlugin.automationEvents.removeAt(position)
|
||||
notifyItemRemoved(position)
|
||||
rxBus.send(EventAutomationDataChanged())
|
||||
rxBus.send(EventAutomationUpdateGui())
|
||||
}, Runnable { rxBus.send(EventAutomationUpdateGui())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = automationPlugin.automationEvents.size
|
||||
|
@ -219,6 +230,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener {
|
|||
val rootLayout: RelativeLayout = view.findViewById(R.id.rootLayout)
|
||||
val iconLayout: LinearLayout = view.findViewById(R.id.iconLayout)
|
||||
val eventTitle: TextView = view.findViewById(R.id.viewEventTitle)
|
||||
val iconTrash: ImageView = view.findViewById(R.id.iconTrash)
|
||||
val iconSort: ImageView = view.findViewById(R.id.iconSort)
|
||||
val enabled: CheckBox = view.findViewById(R.id.automation_enabled)
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) {
|
|||
|
||||
override fun friendlyName(): Int = R.string.starttemptarget
|
||||
override fun shortDescription(): String = resourceHelper.gs(R.string.starttemptarget) + ": " + tt().friendlyDescription(value.units, resourceHelper)
|
||||
@DrawableRes override fun icon(): Int = R.drawable.ic_cp_cgm_target
|
||||
@DrawableRes override fun icon(): Int = R.drawable.ic_temptarget_high
|
||||
|
||||
override fun doAction(callback: Callback) {
|
||||
activePlugin.activeTreatments.addToHistoryTempTarget(tt())
|
||||
|
|
|
@ -113,7 +113,7 @@ class EditEventDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun submit(): Boolean {
|
||||
// check for title
|
||||
val title = automation_inputEventTitle.text.toString()
|
||||
val title = automation_inputEventTitle?.text?.toString() ?: return false
|
||||
if (title.isEmpty()) {
|
||||
ToastUtils.showToastInUiThread(context, R.string.automation_missing_task_name)
|
||||
return false
|
||||
|
|
|
@ -21,7 +21,7 @@ class SimpleItemTouchHelperCallback(private val mAdapter: ItemTouchHelperAdapter
|
|||
}
|
||||
|
||||
override fun isItemViewSwipeEnabled(): Boolean {
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int { // Set movement flags based on the layout manager
|
||||
|
|
|
@ -46,7 +46,7 @@ class TriggerBg(injector: HasAndroidInjector) : Trigger(injector) {
|
|||
}
|
||||
|
||||
override fun shouldRun(): Boolean {
|
||||
val glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
|
||||
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
|
||||
if (glucoseStatus == null && comparator.value == Comparator.Compare.IS_NOT_AVAILABLE) {
|
||||
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
|
||||
return true
|
||||
|
|
|
@ -58,7 +58,7 @@ class TriggerDelta(injector: HasAndroidInjector) : Trigger(injector) {
|
|||
}
|
||||
|
||||
override fun shouldRun(): Boolean {
|
||||
val glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
|
||||
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
|
||||
?: return if (comparator.value == Comparator.Compare.IS_NOT_AVAILABLE) {
|
||||
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
|
||||
true
|
||||
|
|
|
@ -105,9 +105,7 @@ public class Food {
|
|||
return false;
|
||||
if (!Objects.equals(subcategory, other.subcategory))
|
||||
return false;
|
||||
if (!Objects.equals(units, other.units))
|
||||
return false;
|
||||
return true;
|
||||
return Objects.equals(units, other.units);
|
||||
}
|
||||
|
||||
public void copyFrom(Food other) {
|
||||
|
|
|
@ -49,7 +49,7 @@ class FoodFragment : DaggerFragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
food_recyclerview.setHasFixedSize(true)
|
||||
food_recyclerview.setLayoutManager(LinearLayoutManager(view.context))
|
||||
food_recyclerview.layoutManager = LinearLayoutManager(view.context)
|
||||
food_recyclerview.adapter = RecyclerViewAdapter(foodPlugin.service?.foodData ?: ArrayList())
|
||||
|
||||
food_clearfilter.setOnClickListener {
|
||||
|
@ -69,7 +69,7 @@ class FoodFragment : DaggerFragment() {
|
|||
filterData()
|
||||
}
|
||||
}
|
||||
food_subcategory.setOnItemSelectedListener(object : AdapterView.OnItemSelectedListener {
|
||||
food_subcategory.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
filterData()
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class FoodFragment : DaggerFragment() {
|
|||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||
filterData()
|
||||
}
|
||||
})
|
||||
}
|
||||
food_filter.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||
|
|
|
@ -48,7 +48,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
|||
@Inject RxBusWrapper rxBus;
|
||||
@Inject FabricPrivacy fabricPrivacy;
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor();
|
||||
private static ScheduledFuture<?> scheduledFoodEventPost = null;
|
||||
|
|
|
@ -1,24 +1,27 @@
|
|||
package info.nightscout.androidaps.plugins.general.maintenance
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.bluetooth.BluetoothAdapter
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.provider.Settings
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import info.nightscout.androidaps.BuildConfig
|
||||
import info.nightscout.androidaps.MainActivity
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.PreferencesActivity
|
||||
import info.nightscout.androidaps.activities.SingleFragmentActivity
|
||||
import info.nightscout.androidaps.events.EventAppExit
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.*
|
||||
import info.nightscout.androidaps.utils.AndroidPermission
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
|
@ -41,12 +44,6 @@ import javax.inject.Singleton
|
|||
* Created by mike on 03.07.2016.
|
||||
*/
|
||||
|
||||
private const val REQUEST_EXTERNAL_STORAGE = 1
|
||||
private val PERMISSIONS_STORAGE = arrayOf(
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
|
||||
@Singleton
|
||||
class ImportExportPrefs @Inject constructor(
|
||||
private var log: AAPSLogger,
|
||||
|
@ -55,6 +52,7 @@ class ImportExportPrefs @Inject constructor(
|
|||
private val buildHelper: BuildHelper,
|
||||
private val rxBus: RxBusWrapper,
|
||||
private val passwordCheck: PasswordCheck,
|
||||
private val androidPermission: AndroidPermission,
|
||||
private val classicPrefsFormat: ClassicPrefsFormat,
|
||||
private val encryptedPrefsFormat: EncryptedPrefsFormat,
|
||||
private val prefFileList: PrefFileListProvider
|
||||
|
@ -70,13 +68,18 @@ class ImportExportPrefs @Inject constructor(
|
|||
f.activity?.let { exportSharedPreferences(it) }
|
||||
}
|
||||
|
||||
fun verifyStoragePermissions(fragment: Fragment) {
|
||||
fragment.context?.let {
|
||||
val permission = ContextCompat.checkSelfPermission(it,
|
||||
fun verifyStoragePermissions(fragment: Fragment, onGranted: Runnable) {
|
||||
fragment.context?.let { ctx ->
|
||||
val permission = ContextCompat.checkSelfPermission(ctx,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||
// We don't have permission so prompt the user
|
||||
fragment.requestPermissions(PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE)
|
||||
fragment.activity?.let {
|
||||
androidPermission.askForPermission(it, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE), AndroidPermission.CASE_STORAGE)
|
||||
}
|
||||
} else {
|
||||
onGranted.run()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +125,7 @@ class ImportExportPrefs @Inject constructor(
|
|||
private fun prefsEncryptionIsDisabled() =
|
||||
buildHelper.isEngineeringMode() && !sp.getBoolean(resourceHelper.gs(R.string.key_maintenance_encrypt_exported_prefs), true)
|
||||
|
||||
private fun askForMasterPass(activity: Activity, @StringRes canceledMsg: Int, then: ((password: String) -> Unit)) {
|
||||
private fun askForMasterPass(activity: FragmentActivity, @StringRes canceledMsg: Int, then: ((password: String) -> Unit)) {
|
||||
passwordCheck.queryPassword(activity, R.string.master_password, R.string.key_master_password, { password ->
|
||||
then(password)
|
||||
}, {
|
||||
|
@ -130,7 +133,7 @@ class ImportExportPrefs @Inject constructor(
|
|||
})
|
||||
}
|
||||
|
||||
private fun askForEncryptionPass(activity: Activity, @StringRes canceledMsg: Int, @StringRes passwordName: Int, @StringRes passwordExplanation: Int?,
|
||||
private fun askForEncryptionPass(activity: FragmentActivity, @StringRes canceledMsg: Int, @StringRes passwordName: Int, @StringRes passwordExplanation: Int?,
|
||||
@StringRes passwordWarning: Int?, then: ((password: String) -> Unit)) {
|
||||
passwordCheck.queryAnyPassword(activity, passwordName, R.string.key_master_password, passwordExplanation, passwordWarning, { password ->
|
||||
then(password)
|
||||
|
@ -139,7 +142,7 @@ class ImportExportPrefs @Inject constructor(
|
|||
})
|
||||
}
|
||||
|
||||
private fun askForMasterPassIfNeeded(activity: Activity, @StringRes canceledMsg: Int, then: ((password: String) -> Unit)) {
|
||||
private fun askForMasterPassIfNeeded(activity: FragmentActivity, @StringRes canceledMsg: Int, then: ((password: String) -> Unit)) {
|
||||
if (prefsEncryptionIsDisabled()) {
|
||||
then("")
|
||||
} else {
|
||||
|
@ -147,7 +150,7 @@ class ImportExportPrefs @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun assureMasterPasswordSet(activity: Activity, @StringRes wrongPwdTitle: Int): Boolean {
|
||||
private fun assureMasterPasswordSet(activity: FragmentActivity, @StringRes wrongPwdTitle: Int): Boolean {
|
||||
if (!sp.contains(R.string.key_master_password) || (sp.getString(R.string.key_master_password, "") == "")) {
|
||||
WarningDialog.showWarning(activity,
|
||||
resourceHelper.gs(wrongPwdTitle),
|
||||
|
@ -163,23 +166,22 @@ class ImportExportPrefs @Inject constructor(
|
|||
return true
|
||||
}
|
||||
|
||||
private fun askToConfirmExport(activity: Activity, fileToExport: File, then: ((password: String) -> Unit)) {
|
||||
private fun askToConfirmExport(activity: FragmentActivity, fileToExport: File, then: ((password: String) -> Unit)) {
|
||||
if (!prefsEncryptionIsDisabled() && !assureMasterPasswordSet(activity, R.string.nav_export)) return
|
||||
|
||||
TwoMessagesAlertDialog.showAlert(activity, resourceHelper.gs(R.string.nav_export),
|
||||
resourceHelper.gs(R.string.export_to) + " " + fileToExport + " ?",
|
||||
resourceHelper.gs(R.string.export_to) + " " + fileToExport.name + " ?",
|
||||
resourceHelper.gs(R.string.password_preferences_encrypt_prompt), {
|
||||
askForMasterPassIfNeeded(activity, R.string.preferences_export_canceled, then)
|
||||
}, null, R.drawable.ic_header_export)
|
||||
}
|
||||
|
||||
private fun askToConfirmImport(activity: Activity, fileToImport: PrefsFile, then: ((password: String) -> Unit)) {
|
||||
private fun askToConfirmImport(activity: FragmentActivity, fileToImport: PrefsFile, then: ((password: String) -> Unit)) {
|
||||
|
||||
if (fileToImport.handler == PrefsFormatsHandler.ENCRYPTED) {
|
||||
if (!assureMasterPasswordSet(activity, R.string.nav_import)) return
|
||||
|
||||
TwoMessagesAlertDialog.showAlert(activity, resourceHelper.gs(R.string.nav_import),
|
||||
resourceHelper.gs(R.string.import_from) + " " + fileToImport.file + " ?",
|
||||
resourceHelper.gs(R.string.import_from) + " " + fileToImport.name + " ?",
|
||||
resourceHelper.gs(R.string.password_preferences_decrypt_prompt), {
|
||||
askForMasterPass(activity, R.string.preferences_import_canceled, then)
|
||||
}, null, R.drawable.ic_header_import)
|
||||
|
@ -191,7 +193,7 @@ class ImportExportPrefs @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun promptForDecryptionPasswordIfNeeded(activity: Activity, prefs: Prefs, importOk: Boolean,
|
||||
private fun promptForDecryptionPasswordIfNeeded(activity: FragmentActivity, prefs: Prefs, importOk: Boolean,
|
||||
format: PrefsFormat, importFile: PrefsFile, then: ((prefs: Prefs, importOk: Boolean) -> Unit)) {
|
||||
|
||||
// current master password was not the one used for decryption, so we prompt for old password...
|
||||
|
@ -206,14 +208,14 @@ class ImportExportPrefs @Inject constructor(
|
|||
// import is OK when we do not have errors (warnings are allowed)
|
||||
val importOkCheckedAgain = checkIfImportIsOk(prefsReloaded)
|
||||
|
||||
then(prefsReloaded, importOkCheckedAgain);
|
||||
then(prefsReloaded, importOkCheckedAgain)
|
||||
}
|
||||
} else {
|
||||
then(prefs, importOk);
|
||||
then(prefs, importOk)
|
||||
}
|
||||
}
|
||||
|
||||
private fun exportSharedPreferences(activity: Activity) {
|
||||
private fun exportSharedPreferences(activity: FragmentActivity) {
|
||||
|
||||
prefFileList.ensureExportDirExists()
|
||||
val legacyFile = prefFileList.legacyFile()
|
||||
|
@ -262,14 +264,12 @@ class ImportExportPrefs @Inject constructor(
|
|||
}
|
||||
|
||||
fun importSharedPreferences(activity: FragmentActivity) {
|
||||
val callForPrefFile = activity.registerForActivityResult(PrefsFileContract()) {
|
||||
it?.let {
|
||||
importSharedPreferences(activity, it)
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
callForPrefFile.launch(null)
|
||||
if (activity is SingleFragmentActivity)
|
||||
activity.callForPrefFile.launch(null)
|
||||
if (activity is MainActivity)
|
||||
activity.callForPrefFile.launch(null)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
// this exception happens on some early implementations of ActivityResult contracts
|
||||
// when registered and called for the second time
|
||||
|
@ -278,12 +278,12 @@ class ImportExportPrefs @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun importSharedPreferences(activity: Activity, importFile: PrefsFile) {
|
||||
fun importSharedPreferences(activity: FragmentActivity, importFile: PrefsFile) {
|
||||
|
||||
askToConfirmImport(activity, importFile) { password ->
|
||||
|
||||
val format: PrefsFormat = when (importFile.handler) {
|
||||
PrefsFormatsHandler.CLASSIC -> classicPrefsFormat
|
||||
PrefsFormatsHandler.CLASSIC -> classicPrefsFormat
|
||||
PrefsFormatsHandler.ENCRYPTED -> encryptedPrefsFormat
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,7 @@ class ImportExportPrefs @Inject constructor(
|
|||
|
||||
for ((_, value) in prefs.metadata) {
|
||||
if (value.status == PrefsStatus.ERROR)
|
||||
importOk = false;
|
||||
importOk = false
|
||||
}
|
||||
return importOk
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ class ImportExportPrefs @Inject constructor(
|
|||
show(context, resourceHelper.gs(R.string.setting_imported), resourceHelper.gs(R.string.restartingapp), Runnable {
|
||||
log.debug(TAG, "Exiting")
|
||||
rxBus.send(EventAppExit())
|
||||
if (context is Activity) {
|
||||
if (context is AppCompatActivity) {
|
||||
context.finish()
|
||||
}
|
||||
System.runFinalization()
|
||||
|
|
|
@ -46,13 +46,15 @@ class MaintenanceFragment : DaggerFragment() {
|
|||
}
|
||||
nav_export.setOnClickListener {
|
||||
// start activity for checking permissions...
|
||||
importExportPrefs.verifyStoragePermissions(this)
|
||||
importExportPrefs.exportSharedPreferences(this)
|
||||
importExportPrefs.verifyStoragePermissions(this) {
|
||||
importExportPrefs.exportSharedPreferences(this)
|
||||
}
|
||||
}
|
||||
nav_import.setOnClickListener {
|
||||
// start activity for checking permissions...
|
||||
importExportPrefs.verifyStoragePermissions(this)
|
||||
importExportPrefs.importSharedPreferences(this)
|
||||
importExportPrefs.verifyStoragePermissions(this) {
|
||||
importExportPrefs.importSharedPreferences(this)
|
||||
}
|
||||
}
|
||||
nav_logsettings.setOnClickListener { startActivity(Intent(activity, LogSettingActivity::class.java)) }
|
||||
}
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
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 androidx.fragment.app.FragmentActivity
|
||||
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
|
||||
|
@ -34,6 +32,7 @@ enum class PrefsImportDir {
|
|||
|
||||
@Parcelize
|
||||
data class PrefsFile(
|
||||
val name: String,
|
||||
val file: File,
|
||||
val baseDir: File,
|
||||
val dirKind: PrefsImportDir,
|
||||
|
@ -46,13 +45,14 @@ data class PrefsFile(
|
|||
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
|
||||
FragmentActivity.RESULT_OK -> intent?.getParcelableExtra(OUTPUT_PARAM)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,7 @@ class PrefFileListProvider @Inject constructor(
|
|||
) {
|
||||
|
||||
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
|
||||
|
@ -96,7 +97,7 @@ class PrefFileListProvider @Inject constructor(
|
|||
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)))
|
||||
prefFiles.add(PrefsFile(it.name, it, path, PrefsImportDir.ROOT_DIR, formatHandler, metadataFor(loadMetadata, formatHandler, contents)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +105,7 @@ class PrefFileListProvider @Inject constructor(
|
|||
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)))
|
||||
prefFiles.add(PrefsFile(it.name, it, aapsPath, PrefsImportDir.AAPS_DIR, PrefsFormatsHandler.ENCRYPTED, metadataFor(loadMetadata, PrefsFormatsHandler.ENCRYPTED, contents)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,10 +167,10 @@ class PrefFileListProvider @Inject constructor(
|
|||
|
||||
meta[PrefsMetadataKey.CREATED_AT]?.let { createdAt ->
|
||||
try {
|
||||
val date1 = DateTime.parse(createdAt.value);
|
||||
val date1 = DateTime.parse(createdAt.value)
|
||||
val date2 = DateTime.now()
|
||||
|
||||
val daysOld = Days.daysBetween(date1.toLocalDate(), date2.toLocalDate()).getDays()
|
||||
val daysOld = Days.daysBetween(date1.toLocalDate(), date2.toLocalDate()).days
|
||||
|
||||
if (daysOld > IMPORT_AGE_NOT_YET_OLD_DAYS) {
|
||||
createdAt.status = PrefsStatus.WARN
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.general.maintenance.activities
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
|
@ -9,6 +8,7 @@ import android.view.MenuItem
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import dagger.android.support.DaggerAppCompatActivity
|
||||
|
@ -63,7 +63,7 @@ class PrefImportListActivity : DaggerAppCompatActivity() {
|
|||
val i = Intent()
|
||||
|
||||
i.putExtra(PrefsFileContract.OUTPUT_PARAM, prefFile)
|
||||
setResult(Activity.RESULT_OK, i)
|
||||
setResult(FragmentActivity.RESULT_OK, i)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class ClassicPrefsFormat @Inject constructor(
|
|||
|
||||
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)
|
||||
return contents.contains("units::" + Constants.MGDL) || contents.contains("units::" + Constants.MMOL) || contents.contains("language::") || contents.contains("I_understand::")
|
||||
}
|
||||
|
||||
override fun savePreferences(file: File, prefs: Prefs, masterPassword: String?) {
|
||||
|
|
|
@ -244,7 +244,7 @@ class EncryptedPrefsFormat @Inject constructor(
|
|||
metadata[PrefsMetadataKey.FILE_FORMAT] = PrefMetadata(resourceHelper.gs(R.string.prefdecrypt_wrong_json), PrefsStatus.ERROR)
|
||||
}
|
||||
|
||||
return metadata;
|
||||
return metadata
|
||||
}
|
||||
|
||||
}
|
|
@ -37,7 +37,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
|||
@Inject UploadQueue uploadQueue;
|
||||
@Inject FabricPrivacy fabricPrivacy;
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
private TextView logTextView;
|
||||
private TextView queueTextView;
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.os.IBinder;
|
|||
import android.text.Spanned;
|
||||
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -50,7 +51,7 @@ import io.reactivex.schedulers.Schedulers;
|
|||
|
||||
@Singleton
|
||||
public class NSClientPlugin extends PluginBase {
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
private final AAPSLogger aapsLogger;
|
||||
private final RxBusWrapper rxBus;
|
||||
|
@ -72,7 +73,7 @@ public class NSClientPlugin extends PluginBase {
|
|||
|
||||
public NSClientService nsClientService = null;
|
||||
|
||||
private NsClientReceiverDelegate nsClientReceiverDelegate;
|
||||
private final NsClientReceiverDelegate nsClientReceiverDelegate;
|
||||
|
||||
@Inject
|
||||
public NSClientPlugin(
|
||||
|
@ -190,11 +191,25 @@ public class NSClientPlugin extends PluginBase {
|
|||
super.preprocessPreferences(preferenceFragment);
|
||||
|
||||
if (config.getNSCLIENT()) {
|
||||
preferenceFragment.findPreference(resourceHelper.gs(R.string.key_statuslights_overview_advanced));
|
||||
SwitchPreference key_ns_uploadlocalprofile = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_ns_uploadlocalprofile));
|
||||
if (key_ns_uploadlocalprofile != null) key_ns_uploadlocalprofile.setVisible(false);
|
||||
SwitchPreference key_ns_autobackfill = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_ns_autobackfill));
|
||||
if (key_ns_autobackfill != null) key_ns_autobackfill.setVisible(false);
|
||||
SwitchPreference key_ns_create_announcements_from_errors = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_ns_create_announcements_from_errors));
|
||||
if (key_ns_create_announcements_from_errors != null) key_ns_create_announcements_from_errors.setVisible(false);
|
||||
SwitchPreference key_ns_create_announcements_from_carbs_req = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_ns_create_announcements_from_carbs_req));
|
||||
if (key_ns_create_announcements_from_carbs_req != null) key_ns_create_announcements_from_carbs_req.setVisible(false);
|
||||
SwitchPreference key_ns_upload_only = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_ns_upload_only));
|
||||
if (key_ns_upload_only != null) {
|
||||
key_ns_upload_only.setVisible(false);
|
||||
key_ns_upload_only.setEnabled(false);
|
||||
}
|
||||
SwitchPreference key_ns_sync_use_absolute = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_ns_sync_use_absolute));
|
||||
if (key_ns_sync_use_absolute != null) key_ns_sync_use_absolute.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
private final ServiceConnection mConnection = new ServiceConnection() {
|
||||
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
aapsLogger.debug(LTag.NSCLIENT, "Service is disconnected");
|
||||
|
@ -261,7 +276,7 @@ public class NSClientPlugin extends PluginBase {
|
|||
}
|
||||
|
||||
public boolean hasWritePermission() {
|
||||
return nsClientService.hasWriteAuth;
|
||||
return NSClientService.hasWriteAuth;
|
||||
}
|
||||
|
||||
public void handleClearAlarm(NSAlarm originalAlarm, long silenceTimeInMsec) {
|
||||
|
|
|
@ -15,10 +15,13 @@ import javax.inject.Inject;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.ConfigInterface;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.RunningConfiguration;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.HtmlHelper;
|
||||
import info.nightscout.androidaps.utils.Round;
|
||||
|
@ -85,6 +88,8 @@ public class NSDeviceStatus {
|
|||
private final SP sp;
|
||||
private final ResourceHelper resourceHelper;
|
||||
private final NSSettingsStatus nsSettingsStatus;
|
||||
private final ConfigInterface config;
|
||||
private final RunningConfiguration runningConfiguration;
|
||||
|
||||
private JSONObject data = null;
|
||||
|
||||
|
@ -93,12 +98,16 @@ public class NSDeviceStatus {
|
|||
AAPSLogger aapsLogger,
|
||||
SP sp,
|
||||
ResourceHelper resourceHelper,
|
||||
NSSettingsStatus nsSettingsStatus
|
||||
NSSettingsStatus nsSettingsStatus,
|
||||
ConfigInterface config,
|
||||
RunningConfiguration runningConfiguration
|
||||
) {
|
||||
this.aapsLogger = aapsLogger;
|
||||
this.sp = sp;
|
||||
this.resourceHelper = resourceHelper;
|
||||
this.nsSettingsStatus = nsSettingsStatus;
|
||||
this.config = config;
|
||||
this.runningConfiguration = runningConfiguration;
|
||||
}
|
||||
|
||||
public void handleNewData(JSONArray devicestatuses) {
|
||||
|
@ -114,8 +123,13 @@ public class NSDeviceStatus {
|
|||
// Objectives 0
|
||||
sp.putBoolean(R.string.key_ObjectivespumpStatusIsAvailableInNS, true);
|
||||
}
|
||||
if (devicestatusJson.has("configuration") && config.getNSCLIENT()) {
|
||||
// copy configuration of Insulin and Sensitivity from main AAPS
|
||||
runningConfiguration.apply(devicestatusJson.getJSONObject("configuration"));
|
||||
}
|
||||
}
|
||||
} catch (JSONException ignored) {
|
||||
} catch (JSONException jsonException) {
|
||||
jsonException.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -375,7 +389,7 @@ public class NSDeviceStatus {
|
|||
|
||||
// ********* Uploader data ***********
|
||||
|
||||
private static HashMap<String, Uploader> uploaders = new HashMap<>();
|
||||
private static final HashMap<String, Uploader> uploaders = new HashMap<>();
|
||||
|
||||
static class Uploader {
|
||||
long clock = 0L;
|
||||
|
|
|
@ -10,9 +10,9 @@ import info.nightscout.androidaps.logging.LTag;
|
|||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||
|
||||
public class NSTreatment {
|
||||
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
||||
private static final Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
||||
|
||||
private JSONObject data;
|
||||
private final JSONObject data;
|
||||
private String action = null; // "update", "remove" or null (add)
|
||||
|
||||
public NSTreatment(JSONObject obj) {
|
||||
|
|
|
@ -91,10 +91,10 @@ public class NSClientService extends DaggerService {
|
|||
@Inject DateUtil dateUtil;
|
||||
@Inject UploadQueue uploadQueue;
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
static public PowerManager.WakeLock mWakeLock;
|
||||
private IBinder mBinder = new NSClientService.LocalBinder();
|
||||
private final IBinder mBinder = new NSClientService.LocalBinder();
|
||||
|
||||
static ProfileStore profileStore;
|
||||
|
||||
|
@ -123,9 +123,9 @@ public class NSClientService extends DaggerService {
|
|||
private String nsAPIhashCode = "";
|
||||
|
||||
private final ArrayList<Long> reconnections = new ArrayList<>();
|
||||
private int WATCHDOG_INTERVAL_MINUTES = 2;
|
||||
private int WATCHDOG_RECONNECT_IN = 15;
|
||||
private int WATCHDOG_MAXCONNECTIONS = 5;
|
||||
private final int WATCHDOG_INTERVAL_MINUTES = 2;
|
||||
private final int WATCHDOG_RECONNECT_IN = 15;
|
||||
private final int WATCHDOG_MAXCONNECTIONS = 5;
|
||||
|
||||
public NSClientService() {
|
||||
super();
|
||||
|
@ -322,7 +322,7 @@ public class NSClientService extends DaggerService {
|
|||
}
|
||||
}
|
||||
|
||||
private Emitter.Listener onConnect = new Emitter.Listener() {
|
||||
private final Emitter.Listener onConnect = new Emitter.Listener() {
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
connectCounter++;
|
||||
|
@ -360,7 +360,7 @@ public class NSClientService extends DaggerService {
|
|||
}
|
||||
}
|
||||
|
||||
private Emitter.Listener onDisconnect = new Emitter.Listener() {
|
||||
private final Emitter.Listener onDisconnect = new Emitter.Listener() {
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
aapsLogger.debug(LTag.NSCLIENT, "disconnect reason: {}", args);
|
||||
|
@ -412,7 +412,7 @@ public class NSClientService extends DaggerService {
|
|||
nsDevice = sp.getString("careportal_enteredby", "");
|
||||
}
|
||||
|
||||
private Emitter.Listener onError = new Emitter.Listener() {
|
||||
private final Emitter.Listener onError = new Emitter.Listener() {
|
||||
@Override
|
||||
public void call(final Object... args) {
|
||||
String msg = "Unknown Error";
|
||||
|
@ -423,7 +423,7 @@ public class NSClientService extends DaggerService {
|
|||
}
|
||||
};
|
||||
|
||||
private Emitter.Listener onPing = new Emitter.Listener() {
|
||||
private final Emitter.Listener onPing = new Emitter.Listener() {
|
||||
@Override
|
||||
public void call(final Object... args) {
|
||||
rxBus.send(new EventNSClientNewLog("PING", "received"));
|
||||
|
@ -432,7 +432,7 @@ public class NSClientService extends DaggerService {
|
|||
}
|
||||
};
|
||||
|
||||
private Emitter.Listener onAnnouncement = new Emitter.Listener() {
|
||||
private final Emitter.Listener onAnnouncement = new Emitter.Listener() {
|
||||
/*
|
||||
{
|
||||
"level":0,
|
||||
|
@ -456,7 +456,7 @@ public class NSClientService extends DaggerService {
|
|||
}
|
||||
};
|
||||
|
||||
private Emitter.Listener onAlarm = new Emitter.Listener() {
|
||||
private final Emitter.Listener onAlarm = new Emitter.Listener() {
|
||||
/*
|
||||
{
|
||||
"level":1,
|
||||
|
@ -482,7 +482,7 @@ public class NSClientService extends DaggerService {
|
|||
}
|
||||
};
|
||||
|
||||
private Emitter.Listener onUrgentAlarm = args -> {
|
||||
private final Emitter.Listener onUrgentAlarm = args -> {
|
||||
JSONObject data;
|
||||
try {
|
||||
data = (JSONObject) args[0];
|
||||
|
@ -492,7 +492,7 @@ public class NSClientService extends DaggerService {
|
|||
}
|
||||
};
|
||||
|
||||
private Emitter.Listener onClearAlarm = new Emitter.Listener() {
|
||||
private final Emitter.Listener onClearAlarm = new Emitter.Listener() {
|
||||
/*
|
||||
{
|
||||
"clear":true,
|
||||
|
@ -516,7 +516,7 @@ public class NSClientService extends DaggerService {
|
|||
}
|
||||
};
|
||||
|
||||
private Emitter.Listener onDataUpdate = new Emitter.Listener() {
|
||||
private final Emitter.Listener onDataUpdate = new Emitter.Listener() {
|
||||
@Override
|
||||
public void call(final Object... args) {
|
||||
NSClientService.handler.post(() -> {
|
||||
|
|
|
@ -185,7 +185,7 @@ private val allowedKeys = """
|
|||
tidepool_only_while_charging
|
||||
tidepool_only_while_unmetered
|
||||
virtualpump
|
||||
virtualpump_uploadstatus
|
||||
key_virtualpump_uploadstatus
|
||||
virtualpump_type
|
||||
wearplugin
|
||||
wearcontrol
|
||||
|
|
|
@ -43,8 +43,8 @@ class OpenHumansAPI(
|
|||
.toSingle()
|
||||
.map { response ->
|
||||
response.use { _ ->
|
||||
val body = response.body
|
||||
val jsonObject = body?.let { JSONObject(it.string()) }
|
||||
val responseBody = response.body
|
||||
val jsonObject = responseBody?.let { JSONObject(it.string()) }
|
||||
if (!response.isSuccessful) throw OHHttpException(response.code, response.message, jsonObject?.getString("error"))
|
||||
if (jsonObject == null) throw OHHttpException(response.code, response.message, "No body")
|
||||
if (!jsonObject.has("expires_in")) throw OHMissingFieldException("expires_in")
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.general.openhumans
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
|
@ -11,6 +10,7 @@ import android.widget.Toast
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import dagger.android.support.DaggerDialogFragment
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||
|
@ -26,7 +26,7 @@ class OpenHumansLoginActivity : NoSplashAppCompatActivity() {
|
|||
val button = findViewById<Button>(R.id.button)
|
||||
val checkbox = findViewById<CheckBox>(R.id.checkbox)
|
||||
|
||||
button.setOnClickListener { _ ->
|
||||
button.setOnClickListener {
|
||||
if (checkbox.isChecked) {
|
||||
CustomTabsIntent.Builder().build().launchUrl(this, Uri.parse(OpenHumansUploader.AUTH_URL))
|
||||
} else {
|
||||
|
@ -55,7 +55,7 @@ class OpenHumansLoginActivity : NoSplashAppCompatActivity() {
|
|||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return AlertDialog.Builder(activity!!)
|
||||
return AlertDialog.Builder(requireActivity())
|
||||
.setTitle(R.string.completing_login)
|
||||
.setMessage(R.string.please_wait)
|
||||
.create()
|
||||
|
@ -65,10 +65,10 @@ class OpenHumansLoginActivity : NoSplashAppCompatActivity() {
|
|||
super.onCreate(savedInstanceState)
|
||||
disposable = openHumansUploader.login(arguments?.getString("authToken")!!).subscribeOn(Schedulers.io()).subscribe({
|
||||
dismiss()
|
||||
SetupDoneDialog().show(fragmentManager!!, "SetupDoneDialog")
|
||||
SetupDoneDialog().show(parentFragmentManager, "SetupDoneDialog")
|
||||
}, {
|
||||
dismiss()
|
||||
ErrorDialog(it.message).show(fragmentManager!!, "ErrorDialog")
|
||||
ErrorDialog(it.message).show(parentFragmentManager, "ErrorDialog")
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ class OpenHumansLoginActivity : NoSplashAppCompatActivity() {
|
|||
val message = arguments?.getString("message")
|
||||
val shownMessage = if (message == null) getString(R.string.there_was_an_error)
|
||||
else "${getString(R.string.there_was_an_error)}\n\n$message"
|
||||
return AlertDialog.Builder(activity!!)
|
||||
return AlertDialog.Builder(requireActivity())
|
||||
.setTitle(R.string.error)
|
||||
.setMessage(shownMessage)
|
||||
.setPositiveButton(R.string.close, null)
|
||||
|
@ -122,14 +122,14 @@ class OpenHumansLoginActivity : NoSplashAppCompatActivity() {
|
|||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return AlertDialog.Builder(activity!!)
|
||||
return AlertDialog.Builder(requireActivity())
|
||||
.setTitle(R.string.successfully_logged_in)
|
||||
.setMessage(R.string.setup_will_continue_in_background)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.close) { _, _ ->
|
||||
activity!!.run {
|
||||
setResult(Activity.RESULT_OK)
|
||||
activity!!.finish()
|
||||
requireActivity().run {
|
||||
setResult(FragmentActivity.RESULT_OK)
|
||||
requireActivity().finish()
|
||||
}
|
||||
}
|
||||
.create()
|
||||
|
|
|
@ -564,7 +564,7 @@ class OpenHumansUploader @Inject constructor(
|
|||
creationDate = uploadDate.time
|
||||
),
|
||||
content = bytes,
|
||||
highestQueueId = items.map { it.id }.max()
|
||||
highestQueueId = items.map { it.id }.maxOrNull()
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import android.widget.LinearLayout
|
|||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.text.toSpanned
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.jjoe64.graphview.GraphView
|
||||
import dagger.android.HasAndroidInjector
|
||||
|
@ -56,6 +57,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
|||
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.EventIobCalculationProgress
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||
import info.nightscout.androidaps.plugins.source.DexcomPlugin
|
||||
import info.nightscout.androidaps.plugins.source.XdripPlugin
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
|
@ -80,7 +82,7 @@ import kotlinx.android.synthetic.main.overview_buttons_layout.overview_quickwiza
|
|||
import kotlinx.android.synthetic.main.overview_buttons_layout.overview_treatmentbutton
|
||||
import kotlinx.android.synthetic.main.overview_buttons_layout.overview_wizardbutton
|
||||
import kotlinx.android.synthetic.main.overview_fragment.overview_notifications
|
||||
import kotlinx.android.synthetic.main.overview_fragment_nsclient_tablet.*
|
||||
import kotlinx.android.synthetic.main.overview_fragment_nsclient.*
|
||||
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
|
||||
|
@ -93,10 +95,11 @@ 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_info_layout.overview_time
|
||||
import kotlinx.android.synthetic.main.overview_info_layout.overview_timeagoshort
|
||||
import kotlinx.android.synthetic.main.overview_loop_pumpstatus_layout.*
|
||||
import kotlinx.android.synthetic.main.overview_statuslights_layout.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.*
|
||||
|
@ -181,6 +184,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
// pre-process landscape mode
|
||||
skinProvider.activeSkin().preProcessLandscapeOverviewLayout(dm, view, resourceHelper.gb(R.bool.isTablet))
|
||||
|
||||
overview_pumpstatus?.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder))
|
||||
|
||||
overview_notifications?.setHasFixedSize(false)
|
||||
|
@ -318,11 +324,11 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
if (childFragmentManager.isStateSaved) return
|
||||
activity?.let { activity ->
|
||||
when (v.id) {
|
||||
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, UIRunnable(Runnable { WizardDialog().show(childFragmentManager, "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, UIRunnable(Runnable { onClickQuickWizard() }))
|
||||
R.id.overview_carbsbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { CarbsDialog().show(childFragmentManager, "Overview") }))
|
||||
R.id.overview_treatmentbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { TreatmentDialog().show(childFragmentManager, "Overview") })
|
||||
R.id.overview_wizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { WizardDialog().show(childFragmentManager, "Overview") })
|
||||
R.id.overview_insulinbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { InsulinDialog().show(childFragmentManager, "Overview") })
|
||||
R.id.overview_quickwizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { onClickQuickWizard() })
|
||||
R.id.overview_carbsbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { CarbsDialog().show(childFragmentManager, "Overview") })
|
||||
|
||||
R.id.overview_cgmbutton -> {
|
||||
if (xdripPlugin.isEnabled(PluginType.BGSOURCE))
|
||||
|
@ -357,7 +363,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
loopPlugin.invoke("Accept temp button", false)
|
||||
if (lastRun?.lastAPSRun != null && lastRun.constraintsProcessed?.isChangeRequested == true) {
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.tempbasal_label), lastRun.constraintsProcessed?.toSpanned()
|
||||
?: "".toSpanned(), Runnable {
|
||||
?: "".toSpanned(), {
|
||||
aapsLogger.debug("USER ENTRY: ACCEPT TEMP BASAL")
|
||||
overview_accepttempbutton?.visibility = View.GONE
|
||||
(context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID)
|
||||
|
@ -573,13 +579,15 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
|
||||
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
|
||||
if (glucoseStatus != null) {
|
||||
overview_delta_large?.text = Profile.toSignedUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units)
|
||||
overview_delta_large?.setTextColor(color)
|
||||
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_avgdelta?.text = "${Profile.toSignedUnitsString(glucoseStatus.short_avgdelta, glucoseStatus.short_avgdelta * Constants.MGDL_TO_MMOLL, units)}\n${Profile.toSignedUnitsString(glucoseStatus.long_avgdelta, glucoseStatus.long_avgdelta * Constants.MGDL_TO_MMOLL, units)}"
|
||||
overview_avgdelta?.text = "${Profile.toSignedUnitsString(glucoseStatus.short_avgdelta, glucoseStatus.short_avgdelta * Constants.MGDL_TO_MMOLL, units)}"
|
||||
overview_long_avgdelta?.text = "${Profile.toSignedUnitsString(glucoseStatus.long_avgdelta, glucoseStatus.long_avgdelta * Constants.MGDL_TO_MMOLL, units)}"
|
||||
} else {
|
||||
overview_delta?.text = "Δ " + resourceHelper.gs(R.string.notavailable)
|
||||
overview_deltashort?.text = "---"
|
||||
overview_avgdelta?.text = ""
|
||||
overview_long_avgdelta?.text = ""
|
||||
}
|
||||
|
||||
// strike through if BG is old
|
||||
|
@ -596,53 +604,65 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
}
|
||||
val closedLoopEnabled = constraintChecker.isClosedLoopAllowed()
|
||||
|
||||
// open loop mode
|
||||
// aps mode
|
||||
if (config.APS && pump.pumpDescription.isTempBasalCapable) {
|
||||
overview_apsmode?.visibility = View.VISIBLE
|
||||
overview_time_llayout?.visibility = View.GONE
|
||||
when {
|
||||
loopPlugin.isEnabled() && loopPlugin.isSuperBolus -> {
|
||||
overview_apsmode?.setImageResource(R.drawable.ic_loop_superbolus)
|
||||
overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper)
|
||||
overview_apsmode_text?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
loopPlugin.isDisconnected -> {
|
||||
overview_apsmode?.setImageResource(R.drawable.ic_loop_disconnected)
|
||||
overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper)
|
||||
overview_apsmode_text?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
loopPlugin.isEnabled() && loopPlugin.isSuspended -> {
|
||||
overview_apsmode?.setImageResource(R.drawable.ic_loop_paused)
|
||||
overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper)
|
||||
overview_apsmode_text?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
pump.isSuspended -> {
|
||||
overview_apsmode?.setImageResource(R.drawable.ic_loop_paused)
|
||||
overview_apsmode_text?.text = ""
|
||||
overview_apsmode?.setImageResource(if (pump.pumpDescription.pumpType == PumpType.Insulet_Omnipod) {
|
||||
// For Omnipod, indicate the pump as disconnected when it's suspended.
|
||||
// The only way to 'reconnect' it, is through the Omnipod tab
|
||||
R.drawable.ic_loop_disconnected
|
||||
} else {
|
||||
R.drawable.ic_loop_paused
|
||||
})
|
||||
overview_apsmode_text?.visibility = View.GONE
|
||||
}
|
||||
|
||||
loopPlugin.isEnabled() && closedLoopEnabled.value() && loopPlugin.isLGS -> {
|
||||
overview_apsmode?.setImageResource(R.drawable.ic_loop_lgs)
|
||||
overview_apsmode_text?.text = ""
|
||||
overview_apsmode_text?.visibility = View.GONE
|
||||
}
|
||||
|
||||
loopPlugin.isEnabled() && closedLoopEnabled.value() -> {
|
||||
overview_apsmode?.setImageResource(R.drawable.ic_loop_closed)
|
||||
overview_apsmode_text?.text = ""
|
||||
overview_apsmode_text?.visibility = View.GONE
|
||||
}
|
||||
|
||||
loopPlugin.isEnabled() && !closedLoopEnabled.value() -> {
|
||||
overview_apsmode?.setImageResource(R.drawable.ic_loop_open)
|
||||
overview_apsmode_text?.text = ""
|
||||
overview_apsmode_text?.visibility = View.GONE
|
||||
}
|
||||
|
||||
else -> {
|
||||
overview_apsmode?.setImageResource(R.drawable.ic_loop_disabled)
|
||||
overview_apsmode_text?.text = ""
|
||||
overview_apsmode_text?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//nsclient
|
||||
overview_apsmode?.visibility = View.GONE
|
||||
overview_apsmode_text?.visibility = View.GONE
|
||||
overview_time_llayout?.visibility = View.VISIBLE
|
||||
}
|
||||
val lastRun = loopPlugin.lastRun
|
||||
val predictionsAvailable = if (config.APS) lastRun?.request?.hasPredictions == true else config.NSCLIENT
|
||||
|
@ -671,7 +691,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
|
||||
// Basal, TBR
|
||||
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 { "T:" + activeTemp.toStringVeryShort() }
|
||||
?: resourceHelper.gs(R.string.pump_basebasalrate, profile.basal)
|
||||
overview_basal_llayout?.setOnClickListener {
|
||||
var fullText = "${resourceHelper.gs(R.string.basebasalrate_label)}: ${resourceHelper.gs(R.string.pump_basebasalrate, profile.basal)}"
|
||||
|
@ -692,10 +712,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
|
||||
// Extended bolus
|
||||
val extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis())
|
||||
overview_extendedbolus?.text = if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses) {
|
||||
if (resourceHelper.shortTextMode()) resourceHelper.gs(R.string.pump_basebasalrate, extendedBolus.absoluteRate())
|
||||
else extendedBolus.toStringMedium()
|
||||
} else ""
|
||||
overview_extendedbolus?.text =
|
||||
if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses)
|
||||
resourceHelper.gs(R.string.pump_basebasalrate, extendedBolus.absoluteRate())
|
||||
else ""
|
||||
overview_extendedbolus?.setOnClickListener {
|
||||
if (extendedBolus != null) activity?.let {
|
||||
OKDialog.show(it, resourceHelper.gs(R.string.extended_bolus), extendedBolus.toString())
|
||||
|
@ -720,15 +740,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
treatmentsPlugin.updateTotalIOBTempBasals()
|
||||
val bolusIob = treatmentsPlugin.lastCalculationTreatments.round()
|
||||
val basalIob = treatmentsPlugin.lastCalculationTempBasals.round()
|
||||
overview_iob?.text = when {
|
||||
resourceHelper.shortTextMode() ->
|
||||
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob)
|
||||
overview_iob?.text = resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob)
|
||||
|
||||
else ->
|
||||
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob) + " (" +
|
||||
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob) + "/" +
|
||||
resourceHelper.gs(R.string.formatinsulinunits, basalIob.basaliob) + ")"
|
||||
}
|
||||
overview_iob_llayout?.setOnClickListener {
|
||||
activity?.let {
|
||||
OKDialog.show(it, resourceHelper.gs(R.string.iob),
|
||||
|
@ -741,7 +754,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
|
||||
// Status lights
|
||||
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, null, careportal_pbage, careportal_batterylevel)
|
||||
|
||||
// cob
|
||||
var cobText: String = resourceHelper.gs(R.string.value_unavailable_short)
|
||||
|
@ -792,7 +805,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
} ?: ""
|
||||
|
||||
// ****** GRAPH *******
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.Main) {
|
||||
overview_bggraph ?: return@launch
|
||||
val graphData = GraphData(injector, overview_bggraph, iobCobCalculatorPlugin, treatmentsPlugin)
|
||||
val secondaryGraphsData: ArrayList<GraphData> = ArrayList()
|
||||
|
|
|
@ -28,12 +28,12 @@ import info.nightscout.androidaps.events.EventRefreshOverview
|
|||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||
|
|
|
@ -6,6 +6,7 @@ import dagger.android.HasAndroidInjector
|
|||
import info.nightscout.androidaps.Config
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.events.EventRefreshOverview
|
||||
import info.nightscout.androidaps.interfaces.OverviewInterface
|
||||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
|
@ -16,9 +17,12 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotifi
|
|||
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationStore
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||
import info.nightscout.androidaps.utils.extensions.*
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
@ -28,6 +32,7 @@ class OverviewPlugin @Inject constructor(
|
|||
private val notificationStore: NotificationStore,
|
||||
private val fabricPrivacy: FabricPrivacy,
|
||||
private val rxBus: RxBusWrapper,
|
||||
private val sp: SP,
|
||||
aapsLogger: AAPSLogger,
|
||||
resourceHelper: ResourceHelper,
|
||||
private val config: Config
|
||||
|
@ -41,7 +46,7 @@ class OverviewPlugin @Inject constructor(
|
|||
.preferencesId(R.xml.pref_overview)
|
||||
.description(R.string.description_overview),
|
||||
aapsLogger, resourceHelper, injector
|
||||
) {
|
||||
), OverviewInterface {
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
|
@ -82,4 +87,57 @@ class OverviewPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun configuration(): JSONObject =
|
||||
JSONObject()
|
||||
.putString(R.string.key_quickwizard, sp, resourceHelper)
|
||||
.putInt(R.string.key_eatingsoon_duration, sp, resourceHelper)
|
||||
.putDouble(R.string.key_eatingsoon_target, sp, resourceHelper)
|
||||
.putInt(R.string.key_activity_duration, sp, resourceHelper)
|
||||
.putDouble(R.string.key_activity_target, sp, resourceHelper)
|
||||
.putInt(R.string.key_hypo_duration, sp, resourceHelper)
|
||||
.putDouble(R.string.key_hypo_target, sp, resourceHelper)
|
||||
.putDouble(R.string.key_low_mark, sp, resourceHelper)
|
||||
.putDouble(R.string.key_high_mark, sp, resourceHelper)
|
||||
.putDouble(R.string.key_statuslights_cage_warning, sp, resourceHelper)
|
||||
.putDouble(R.string.key_statuslights_cage_critical, sp, resourceHelper)
|
||||
.putDouble(R.string.key_statuslights_iage_warning, sp, resourceHelper)
|
||||
.putDouble(R.string.key_statuslights_iage_critical, sp, resourceHelper)
|
||||
.putDouble(R.string.key_statuslights_sage_warning, sp, resourceHelper)
|
||||
.putDouble(R.string.key_statuslights_sage_critical, sp, resourceHelper)
|
||||
.putDouble(R.string.key_statuslights_sbat_warning, sp, resourceHelper)
|
||||
.putDouble(R.string.key_statuslights_sbat_critical, sp, resourceHelper)
|
||||
.putDouble(R.string.key_statuslights_bage_warning, sp, resourceHelper)
|
||||
.putDouble(R.string.key_statuslights_bage_critical, sp, resourceHelper)
|
||||
.putDouble(R.string.key_statuslights_res_warning, sp, resourceHelper)
|
||||
.putDouble(R.string.key_statuslights_res_critical, sp, resourceHelper)
|
||||
.putDouble(R.string.key_statuslights_bat_warning, sp, resourceHelper)
|
||||
.putDouble(R.string.key_statuslights_bat_critical, sp, resourceHelper)
|
||||
|
||||
override fun applyConfiguration(configuration: JSONObject) {
|
||||
configuration
|
||||
.storeString(R.string.key_quickwizard, sp, resourceHelper)
|
||||
.storeInt(R.string.key_eatingsoon_duration, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_eatingsoon_target, sp, resourceHelper)
|
||||
.storeInt(R.string.key_activity_duration, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_activity_target, sp, resourceHelper)
|
||||
.storeInt(R.string.key_hypo_duration, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_hypo_target, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_low_mark, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_high_mark, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_statuslights_cage_warning, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_statuslights_cage_critical, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_statuslights_iage_warning, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_statuslights_iage_critical, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_statuslights_sage_warning, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_statuslights_sage_critical, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_statuslights_sbat_warning, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_statuslights_sbat_critical, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_statuslights_bage_warning, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_statuslights_bage_critical, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_statuslights_res_warning, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_statuslights_res_critical, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_statuslights_bat_warning, sp, resourceHelper)
|
||||
.storeDouble(R.string.key_statuslights_bat_critical, sp, resourceHelper)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,14 +27,20 @@ class StatusLightHandler @Inject constructor(
|
|||
/**
|
||||
* applies the extended statusLight subview on the overview fragment
|
||||
*/
|
||||
fun updateStatusLights(careportal_canulaage: TextView?, careportal_insulinage: TextView?, careportal_reservoirlevel: TextView?, careportal_sensorage: TextView?, careportal_pbage: TextView?, careportal_batterylevel: TextView?) {
|
||||
fun updateStatusLights(careportal_canulaage: TextView?, careportal_insulinage: TextView?, careportal_reservoirlevel: TextView?, careportal_sensorage: TextView?, careportal_sensorbatterylevel: TextView?, careportal_pbage: TextView?, careportal_batterylevel: TextView?) {
|
||||
val pump = activePlugin.activePump
|
||||
val bgSource = activePlugin.activeBgSource
|
||||
handleAge(careportal_canulaage, CareportalEvent.SITECHANGE, R.string.key_statuslights_cage_warning, 48.0, R.string.key_statuslights_cage_critical, 72.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_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")
|
||||
if (bgSource.sensorBatteryLevel != -1)
|
||||
handleLevel(careportal_sensorbatterylevel, R.string.key_statuslights_sbat_critical, 5.0, R.string.key_statuslights_sbat_warning, 20.0, bgSource.sensorBatteryLevel.toDouble(), "%")
|
||||
else
|
||||
careportal_sensorbatterylevel?.text = ""
|
||||
}
|
||||
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(), "%")
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
private inner class RecyclerViewAdapter internal constructor(internal var fragmentManager: FragmentManager) : RecyclerView.Adapter<RecyclerViewAdapter.QuickWizardEntryViewHolder>() {
|
||||
private inner class RecyclerViewAdapter(var fragmentManager: FragmentManager) : RecyclerView.Adapter<RecyclerViewAdapter.QuickWizardEntryViewHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QuickWizardEntryViewHolder {
|
||||
return QuickWizardEntryViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.overview_quickwizardlist_item, parent, false), fragmentManager)
|
||||
|
@ -48,7 +48,7 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
override fun getItemCount(): Int = quickWizard.size()
|
||||
|
||||
private inner class QuickWizardEntryViewHolder internal constructor(itemView: View, internal var fragmentManager: FragmentManager) : RecyclerView.ViewHolder(itemView) {
|
||||
private inner class QuickWizardEntryViewHolder(itemView: View, var fragmentManager: FragmentManager) : RecyclerView.ViewHolder(itemView) {
|
||||
val buttonText: TextView = itemView.findViewById(R.id.overview_quickwizard_item_buttonText)
|
||||
val carbs: TextView = itemView.findViewById(R.id.overview_quickwizard_item_carbs)
|
||||
val from: TextView = itemView.findViewById(R.id.overview_quickwizard_item_from)
|
||||
|
|
|
@ -315,7 +315,7 @@ public class AreaGraphSeries<E extends DoubleDataPoint> extends BaseSeries<E> {
|
|||
canvas.drawPath(mPath, paint);
|
||||
canvas.drawPath(mSecondPath, paint);
|
||||
if (mStyles.drawBackground) {
|
||||
canvas.drawRect((float)startX, (float)startY2, endX, endY1, mPaintBackground);
|
||||
canvas.drawRect(startX, startY2, endX, endY1, mPaintBackground);
|
||||
}
|
||||
} else if (mStyles.drawDataPoints) {
|
||||
//fix: last value not drawn as datapoint. Draw first point here, and then on every step the end values (above)
|
||||
|
|
|
@ -11,9 +11,9 @@ import java.io.Serializable;
|
|||
public class DoubleDataPoint implements DataPointInterface, Serializable {
|
||||
private static final long serialVersionUID=1428267322645L;
|
||||
|
||||
private double x;
|
||||
private double y1;
|
||||
private double y2;
|
||||
private final double x;
|
||||
private final double y1;
|
||||
private final double y2;
|
||||
|
||||
public DoubleDataPoint(double x, double y1, double y2) {
|
||||
this.x=x;
|
||||
|
|
|
@ -12,10 +12,10 @@ import java.util.Date;
|
|||
public class ScaledDataPoint implements DataPointInterface, Serializable {
|
||||
private static final long serialVersionUID=1428263342645L;
|
||||
|
||||
private double x;
|
||||
private double y;
|
||||
private final double x;
|
||||
private final double y;
|
||||
|
||||
private Scale scale;
|
||||
private final Scale scale;
|
||||
|
||||
public ScaledDataPoint(double x, double y, Scale scale) {
|
||||
this.x=x;
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.jjoe64.graphview.DefaultLabelFormatter;
|
|||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by mike on 09.06.2016.
|
||||
|
@ -20,10 +21,22 @@ public class TimeAsXAxisLabelFormatter extends DefaultLabelFormatter {
|
|||
public String formatLabel(double value, boolean isValueX) {
|
||||
if (isValueX) {
|
||||
// format as date
|
||||
DateFormat dateFormat = new SimpleDateFormat(mFormat);
|
||||
DateFormat dateFormat = new SimpleDateFormat(mFormat, Locale.getDefault());
|
||||
return dateFormat.format((long) value);
|
||||
} else {
|
||||
return super.formatLabel(value, isValueX);
|
||||
try {
|
||||
// unknown reason for crashing on this
|
||||
// Fatal Exception: java.lang.NullPointerException
|
||||
// Attempt to invoke virtual method 'double com.jjoe64.graphview.Viewport.getMaxY(boolean)' on a null object reference
|
||||
// com.jjoe64.graphview.DefaultLabelFormatter.formatLabel (DefaultLabelFormatter.java:89)
|
||||
// info.nightscout.androidaps.plugins.general.overview.graphExtensions.TimeAsXAxisLabelFormatter.formatLabel (TimeAsXAxisLabelFormatter.java:26)
|
||||
// com.jjoe64.graphview.GridLabelRenderer.drawVerticalSteps (GridLabelRenderer.java:1057)
|
||||
// com.jjoe64.graphview.GridLabelRenderer.draw (GridLabelRenderer.java:866)
|
||||
// com.jjoe64.graphview.GraphView.onDraw (GraphView.java:296)
|
||||
return super.formatLabel(value, isValueX);
|
||||
} catch (Exception ignored) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
|||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
|
||||
import info.nightscout.androidaps.services.AlarmSoundService
|
||||
import info.nightscout.androidaps.services.AlarmSoundServiceHelper
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.resources.IconsProvider
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
|
@ -39,6 +39,7 @@ class NotificationStore @Inject constructor(
|
|||
private val resourceHelper: ResourceHelper,
|
||||
private val context: Context,
|
||||
private val iconsProvider: IconsProvider,
|
||||
private val alarmSoundServiceHelper: AlarmSoundServiceHelper,
|
||||
private val dateUtil: DateUtil
|
||||
) {
|
||||
|
||||
|
@ -46,10 +47,12 @@ class NotificationStore @Inject constructor(
|
|||
private var usesChannels = false
|
||||
|
||||
companion object {
|
||||
|
||||
private const val CHANNEL_ID = "AndroidAPS-Overview"
|
||||
}
|
||||
|
||||
inner class NotificationComparator : Comparator<Notification> {
|
||||
|
||||
override fun compare(o1: Notification, o2: Notification): Int {
|
||||
return o1.level - o2.level
|
||||
}
|
||||
|
@ -68,17 +71,9 @@ class NotificationStore @Inject constructor(
|
|||
store.add(n)
|
||||
if (sp.getBoolean(R.string.key_raise_notifications_as_android_notifications, false) && n !is NotificationWithAction) {
|
||||
raiseSystemNotification(n)
|
||||
if (usesChannels && n.soundId != null && n.soundId != 0) {
|
||||
val alarm = Intent(context, AlarmSoundService::class.java)
|
||||
alarm.putExtra("soundid", n.soundId)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) context.startForegroundService(alarm) else context.startService(alarm)
|
||||
}
|
||||
if (usesChannels && n.soundId != null && n.soundId != 0) alarmSoundServiceHelper.startAlarm(context, n.soundId)
|
||||
} else {
|
||||
if (n.soundId != null && n.soundId != 0) {
|
||||
val alarm = Intent(context, AlarmSoundService::class.java)
|
||||
alarm.putExtra("soundid", n.soundId)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) context.startForegroundService(alarm) else context.startService(alarm)
|
||||
}
|
||||
if (n.soundId != null && n.soundId != 0) alarmSoundServiceHelper.startAlarm(context, n.soundId)
|
||||
}
|
||||
Collections.sort(store, NotificationComparator())
|
||||
return true
|
||||
|
@ -87,10 +82,7 @@ class NotificationStore @Inject constructor(
|
|||
@Synchronized fun remove(id: Int): Boolean {
|
||||
for (i in store.indices) {
|
||||
if (store[i].id == id) {
|
||||
if (store[i].soundId != null) {
|
||||
val alarm = Intent(context, AlarmSoundService::class.java)
|
||||
context.stopService(alarm)
|
||||
}
|
||||
if (store[i].soundId != null) alarmSoundServiceHelper.stopService(context)
|
||||
store.removeAt(i)
|
||||
return true
|
||||
}
|
||||
|
@ -195,10 +187,10 @@ class NotificationStore @Inject constructor(
|
|||
@Suppress("SetTextI18n")
|
||||
holder.text.text = dateUtil.timeString(notification.date) + " " + notification.text
|
||||
when (notification.level) {
|
||||
Notification.URGENT -> holder.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationUrgent))
|
||||
Notification.NORMAL -> holder.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationNormal))
|
||||
Notification.LOW -> holder.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationLow))
|
||||
Notification.INFO -> holder.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationInfo))
|
||||
Notification.URGENT -> holder.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationUrgent))
|
||||
Notification.NORMAL -> holder.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationNormal))
|
||||
Notification.LOW -> holder.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationLow))
|
||||
Notification.INFO -> holder.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationInfo))
|
||||
Notification.ANNOUNCEMENT -> holder.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationAnnouncement))
|
||||
}
|
||||
}
|
||||
|
@ -208,6 +200,7 @@ class NotificationStore @Inject constructor(
|
|||
}
|
||||
|
||||
inner class NotificationsViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
var cv: CardView = itemView.findViewById(R.id.notification_cardview)
|
||||
var text: TextView = itemView.findViewById(R.id.notification_text)
|
||||
var dismiss: Button = itemView.findViewById(R.id.notification_dismiss)
|
||||
|
|
|
@ -44,7 +44,7 @@ class DummyService : DaggerService() {
|
|||
.subscribe({
|
||||
aapsLogger.debug(LTag.CORE, "EventAppExit received")
|
||||
stopSelf()
|
||||
}) { fabricPrivacy::logException }
|
||||
}, fabricPrivacy::logException )
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ class PersistentNotificationPlugin @Inject constructor(
|
|||
var line1_aa: String
|
||||
val units = profileFunction.getUnits()
|
||||
val lastBG = iobCobCalculatorPlugin.lastBg()
|
||||
val glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
|
||||
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
|
||||
if (lastBG != null) {
|
||||
line1_aa = lastBG.valueToUnitsToString(units)
|
||||
line1 = line1_aa
|
||||
|
|
|
@ -23,7 +23,6 @@ import info.nightscout.androidaps.logging.LTag
|
|||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||
|
@ -290,7 +289,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
val agoMin = (agoMsec / 60.0 / 1000.0).toInt()
|
||||
reply = resourceHelper.gs(R.string.sms_lastbg) + " " + lastBG.valueToUnitsToString(units) + " " + String.format(resourceHelper.gs(R.string.sms_minago), agoMin) + ", "
|
||||
}
|
||||
val glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
|
||||
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
|
||||
if (glucoseStatus != null) reply += resourceHelper.gs(R.string.sms_delta) + " " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", "
|
||||
activePlugin.activeTreatments.updateTotalIOBTreatments()
|
||||
val bolusIob = activePlugin.activeTreatments.lastCalculationTreatments.round()
|
||||
|
@ -314,6 +313,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS LOOP DISABLE")
|
||||
loopPlugin.setPluginEnabled(PluginType.LOOP, false)
|
||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||
override fun run() {
|
||||
|
@ -337,6 +337,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS LOOP ENABLE")
|
||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true)
|
||||
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loophasbeenenabled)))
|
||||
rxBus.send(EventRefreshOverview("SMS_LOOP_START"))
|
||||
|
@ -349,7 +350,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
|
||||
"STATUS" -> {
|
||||
val reply = if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
if (loopPlugin.isSuspended()) String.format(resourceHelper.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend())
|
||||
if (loopPlugin.isSuspended) String.format(resourceHelper.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend())
|
||||
else resourceHelper.gs(R.string.smscommunicator_loopisenabled)
|
||||
} else
|
||||
resourceHelper.gs(R.string.smscommunicator_loopisdisabled)
|
||||
|
@ -363,7 +364,18 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS LOOP RESUME")
|
||||
loopPlugin.suspendTo(0L)
|
||||
rxBus.send(EventRefreshOverview("SMS_LOOP_RESUME"))
|
||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||
override fun run() {
|
||||
if (!result.success) {
|
||||
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
|
||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
||||
}
|
||||
}
|
||||
})
|
||||
loopPlugin.createOfflineEvent(0)
|
||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loopresumed)))
|
||||
}
|
||||
|
@ -385,6 +397,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(duration) {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS LOOP SUSPEND")
|
||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||
override fun run() {
|
||||
if (result.success) {
|
||||
|
@ -463,6 +476,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS PUMP CONNECT")
|
||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||
override fun run() {
|
||||
if (!result.success) {
|
||||
|
@ -491,6 +505,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS PUMP DISCONNECT")
|
||||
val profile = profileFunction.getProfile()
|
||||
loopPlugin.disconnectPump(duration, profile)
|
||||
rxBus.send(EventRefreshOverview("SMS_PUMP_DISCONNECT"))
|
||||
|
@ -544,6 +559,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
val finalPercentage = percentage
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(list[pindex - 1] as String, finalPercentage) {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS PROFILE $reply")
|
||||
activePlugin.activeTreatments.doProfileSwitch(store, list[pindex - 1] as String, 0, finalPercentage, 0, DateUtil.now())
|
||||
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.profileswitchcreated)))
|
||||
}
|
||||
|
@ -561,6 +577,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS BASAL $reply")
|
||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||
override fun run() {
|
||||
if (result.success) {
|
||||
|
@ -578,12 +595,13 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
})
|
||||
} else if (splitted[1].endsWith("%")) {
|
||||
var tempBasalPct = SafeParse.stringToInt(StringUtils.removeEnd(splitted[1], "%"))
|
||||
val durationStep = activePlugin.activePump.model().tbrSettings.durationStep
|
||||
var duration = 30
|
||||
if (splitted.size > 2) duration = SafeParse.stringToInt(splitted[2])
|
||||
val profile = profileFunction.getProfile()
|
||||
if (profile == null) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.noprofile)))
|
||||
else if (tempBasalPct == 0 && splitted[1] != "0%") sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
||||
else if (duration == 0) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
||||
else if (duration <= 0 || duration % durationStep != 0) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongTbrDuration, durationStep)))
|
||||
else {
|
||||
tempBasalPct = constraintChecker.applyBasalPercentConstraints(Constraint(tempBasalPct), profile).value()
|
||||
val passCode = generatePasscode()
|
||||
|
@ -591,6 +609,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(tempBasalPct, duration) {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS BASAL $reply")
|
||||
commandQueue.tempBasalPercent(anInteger(), secondInteger(), true, profile, object : Callback() {
|
||||
override fun run() {
|
||||
if (result.success) {
|
||||
|
@ -610,12 +629,13 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
} else {
|
||||
var tempBasal = SafeParse.stringToDouble(splitted[1])
|
||||
val durationStep = activePlugin.activePump.model().tbrSettings.durationStep
|
||||
var duration = 30
|
||||
if (splitted.size > 2) duration = SafeParse.stringToInt(splitted[2])
|
||||
val profile = profileFunction.getProfile()
|
||||
if (profile == null) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.noprofile)))
|
||||
else if (tempBasal == 0.0 && splitted[1] != "0") sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
||||
else if (duration == 0) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
||||
else if (duration <= 0 || duration % durationStep != 0) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongTbrDuration, durationStep)))
|
||||
else {
|
||||
tempBasal = constraintChecker.applyBasalConstraints(Constraint(tempBasal), profile).value()
|
||||
val passCode = generatePasscode()
|
||||
|
@ -623,6 +643,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(tempBasal, duration) {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS BASAL $reply")
|
||||
commandQueue.tempBasalAbsolute(aDouble(), secondInteger(), true, profile, object : Callback() {
|
||||
override fun run() {
|
||||
if (result.success) {
|
||||
|
@ -650,6 +671,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS EXTENDED $reply")
|
||||
commandQueue.cancelExtended(object : Callback() {
|
||||
override fun run() {
|
||||
if (result.success) {
|
||||
|
@ -678,6 +700,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(extended, duration) {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS EXTENDED $reply")
|
||||
commandQueue.extendedBolus(aDouble(), secondInteger(), object : Callback() {
|
||||
override fun run() {
|
||||
if (result.success) {
|
||||
|
@ -713,6 +736,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(bolus) {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS BOLUS $reply")
|
||||
val detailedBolusInfo = DetailedBolusInfo()
|
||||
detailedBolusInfo.insulin = aDouble()
|
||||
detailedBolusInfo.source = Source.USER
|
||||
|
@ -787,6 +811,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(grams, time) {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS CARBS $reply")
|
||||
val detailedBolusInfo = DetailedBolusInfo()
|
||||
detailedBolusInfo.carbs = anInteger().toDouble()
|
||||
detailedBolusInfo.source = Source.USER
|
||||
|
@ -827,6 +852,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS TARGET $reply")
|
||||
val units = profileFunction.getUnits()
|
||||
var keyDuration = 0
|
||||
var defaultTargetDuration = 0
|
||||
|
@ -882,6 +908,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS TARGET $reply")
|
||||
val tempTarget = TempTarget()
|
||||
.source(Source.USER)
|
||||
.date(DateUtil.now())
|
||||
|
@ -906,6 +933,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS SMS $reply")
|
||||
sp.putBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)
|
||||
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_stoppedsms))
|
||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||
|
@ -922,6 +950,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(cal) {
|
||||
override fun run() {
|
||||
aapsLogger.debug("USER ENTRY: SMS CAL $reply")
|
||||
val result = xdripCalibrations.sendIntent(aDouble!!)
|
||||
if (result) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_calibrationsent))) else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_calibrationfailed)))
|
||||
}
|
||||
|
@ -1002,7 +1031,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
|
||||
private fun areMoreNumbers(allowednumbers: String?): Boolean {
|
||||
return allowednumbers?.let {
|
||||
var countNumbers = 0
|
||||
val knownNumbers = HashSet<String>()
|
||||
val substrings = it.split(";").toTypedArray()
|
||||
for (number in substrings) {
|
||||
var cleaned = number.replace(Regex("\\s+"), "")
|
||||
|
@ -1010,9 +1039,9 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
cleaned = cleaned.replace("+", "")
|
||||
cleaned = cleaned.replace("-", "")
|
||||
if (!cleaned.matches(Regex("[0-9]+"))) continue
|
||||
countNumbers++
|
||||
knownNumbers.add(cleaned)
|
||||
}
|
||||
countNumbers > 1
|
||||
knownNumbers.size > 1
|
||||
} ?: false
|
||||
}
|
||||
}
|
|
@ -1,11 +1,15 @@
|
|||
package info.nightscout.androidaps.plugins.general.smsCommunicator.activities
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import com.google.common.primitives.Ints.min
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
|
||||
import info.nightscout.androidaps.R
|
||||
|
@ -15,8 +19,8 @@ import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicato
|
|||
import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePassword
|
||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePasswordValidationResult
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import kotlinx.android.synthetic.main.activity_smscommunicator_otp.*
|
||||
import net.glxn.qrgen.android.QRCode
|
||||
|
@ -31,6 +35,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
|
||||
setContentView(R.layout.activity_smscommunicator_otp)
|
||||
|
||||
smscommunicator_otp_verify_edit.addTextChangedListener(object : TextWatcher {
|
||||
|
@ -64,9 +69,23 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() {
|
|||
Runnable {
|
||||
otp.ensureKey(true)
|
||||
updateGui()
|
||||
ToastUtils.showToastInUiThread(this, R.string.smscommunicator_otp_reset_successful)
|
||||
ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_reset_successful))
|
||||
})
|
||||
}
|
||||
|
||||
smscommunicator_otp_provisioning.setOnLongClickListener {
|
||||
OKDialog.showConfirmation(this,
|
||||
resourceHelper.gs(R.string.smscommunicator_otp_export_title),
|
||||
resourceHelper.gs(R.string.smscommunicator_otp_export_prompt),
|
||||
Runnable {
|
||||
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = ClipData.newPlainText("OTP Secret", otp.provisioningSecret())
|
||||
clipboard.primaryClip = clip
|
||||
ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_export_successful))
|
||||
})
|
||||
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
|
|
@ -121,4 +121,10 @@ class OneTimePassword @Inject constructor(
|
|||
fun provisioningURI(): String? =
|
||||
key?.let { "otpauth://totp/AndroidAPS:" + URLEncoder.encode(name(), "utf-8").replace("+", "%20") + "?secret=" + BaseEncoding.base32().encode(it.encoded).replace("=", "") + "&issuer=AndroidAPS" }
|
||||
|
||||
/**
|
||||
* Return secret used to provision Authenticator apps, in Base32 format
|
||||
*/
|
||||
fun provisioningSecret(): String? =
|
||||
key?.let { BaseEncoding.base32().encode(it.encoded).replace("=", "") }
|
||||
|
||||
}
|
|
@ -3,9 +3,7 @@ package info.nightscout.androidaps.plugins.general.tidepool.elements
|
|||
import com.google.gson.annotations.Expose
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.db.ProfileSwitch
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.general.tidepool.comm.TidepoolUploader
|
||||
import info.nightscout.androidaps.utils.InstanceId
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
|
|
|
@ -2,10 +2,8 @@ package info.nightscout.androidaps.plugins.general.tidepool.messages
|
|||
|
||||
import com.google.gson.annotations.Expose
|
||||
import info.nightscout.androidaps.BuildConfig
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.general.tidepool.comm.TidepoolUploader
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.InstanceId
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import java.util.*
|
||||
|
||||
|
|
|
@ -19,10 +19,10 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||
* Created by emmablack on 12/26/14.
|
||||
*/
|
||||
class SendToDataLayerThread extends AsyncTask<DataMap,Void,Void> {
|
||||
private GoogleApiClient googleApiClient;
|
||||
private final GoogleApiClient googleApiClient;
|
||||
private static final String TAG = "SendToDataLayerThread";
|
||||
private String path;
|
||||
private String logPrefix = ""; // "WR: ";
|
||||
private final String path;
|
||||
private final String logPrefix = ""; // "WR: ";
|
||||
private static int concurrency = 0;
|
||||
private static int state = 0;
|
||||
private static final ReentrantLock lock = new ReentrantLock();
|
||||
|
|
|
@ -56,6 +56,7 @@ import info.nightscout.androidaps.utils.DefaultValueHelper;
|
|||
import info.nightscout.androidaps.utils.ToastUtils;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
import kotlin.Suppress;
|
||||
|
||||
public class WatchUpdaterService extends WearableListenerService implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
||||
@Inject public HasAndroidInjector injector;
|
||||
|
@ -768,8 +769,9 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
|||
// Log.d(TAG, "WR: " + source + " " + data);
|
||||
}
|
||||
|
||||
@SuppressWarnings("UNCHECKED")
|
||||
private void executeTask(AsyncTask task, DataMap... parameters) {
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Object[]) parameters);
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, parameters);
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
// task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
// } else {
|
||||
|
|
|
@ -22,9 +22,9 @@ class InsulinFragment : DaggerFragment() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
insulin_name?.setText(activePlugin.getActiveInsulin().getFriendlyName())
|
||||
insulin_comment?.setText(activePlugin.getActiveInsulin().getComment())
|
||||
insulin_dia?.text = resourceHelper.gs(R.string.dia) + ": " + activePlugin.getActiveInsulin().getDia() + "h"
|
||||
insulin_graph?.show(activePlugin.getActiveInsulin())
|
||||
insulin_name?.text = activePlugin.activeInsulin.friendlyName
|
||||
insulin_comment?.text = activePlugin.activeInsulin.comment
|
||||
insulin_dia?.text = resourceHelper.gs(R.string.dia) + ": " + activePlugin.activeInsulin.dia + "h"
|
||||
insulin_graph?.show(activePlugin.activeInsulin)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package info.nightscout.androidaps.plugins.insulin
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class InsulinLyumjevPlugin @Inject constructor(
|
||||
injector: HasAndroidInjector,
|
||||
resourceHelper: ResourceHelper,
|
||||
profileFunction: ProfileFunction,
|
||||
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||
) : InsulinOrefBasePlugin(injector, resourceHelper, profileFunction, rxBus, aapsLogger) {
|
||||
|
||||
override val id get(): InsulinInterface.InsulinType = InsulinInterface.InsulinType.OREF_LYUMJEV
|
||||
override val friendlyName get(): String = resourceHelper.gs(R.string.lyumjev)
|
||||
|
||||
override fun configuration(): JSONObject = JSONObject()
|
||||
override fun applyConfiguration(configuration: JSONObject) {}
|
||||
|
||||
override fun commentStandardText(): String = resourceHelper.gs(R.string.lyumjev)
|
||||
|
||||
override val peak = 45
|
||||
|
||||
init {
|
||||
pluginDescription
|
||||
.pluginName(R.string.lyumjev)
|
||||
.description(R.string.description_insulin_lyumjev)
|
||||
}
|
||||
}
|
|
@ -3,16 +3,16 @@ package info.nightscout.androidaps.plugins.insulin
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.data.Iob
|
||||
import info.nightscout.androidaps.db.Treatment
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||
import info.nightscout.androidaps.db.Treatment
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
|
||||
/**
|
||||
|
@ -35,15 +35,16 @@ abstract class InsulinOrefBasePlugin(
|
|||
), InsulinInterface {
|
||||
|
||||
private var lastWarned: Long = 0
|
||||
override fun getDia(): Double {
|
||||
val dia = userDefinedDia
|
||||
return if (dia >= MIN_DIA) {
|
||||
dia
|
||||
} else {
|
||||
sendShortDiaNotification(dia)
|
||||
MIN_DIA
|
||||
override val dia
|
||||
get(): Double {
|
||||
val dia = userDefinedDia
|
||||
return if (dia >= MIN_DIA) {
|
||||
dia
|
||||
} else {
|
||||
sendShortDiaNotification(dia)
|
||||
MIN_DIA
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open fun sendShortDiaNotification(dia: Double) {
|
||||
if (System.currentTimeMillis() - lastWarned > 60 * 1000) {
|
||||
|
@ -62,17 +63,13 @@ abstract class InsulinOrefBasePlugin(
|
|||
return profile?.dia ?: MIN_DIA
|
||||
}
|
||||
|
||||
fun iobCalcForTreatment(treatment: Treatment, time: Long): Iob {
|
||||
return this.iobCalcForTreatment(treatment, time, 0.0)
|
||||
}
|
||||
|
||||
override fun iobCalcForTreatment(treatment: Treatment, time: Long, dia: Double): Iob {
|
||||
val result = Iob()
|
||||
val peak = peak
|
||||
if (treatment.insulin != 0.0) {
|
||||
val bolusTime = treatment.date
|
||||
val t = (time - bolusTime) / 1000.0 / 60.0
|
||||
val td = getDia() * 60 //getDIA() always >= MIN_DIA
|
||||
val td = dia * 60 //getDIA() always >= MIN_DIA
|
||||
val tp = peak.toDouble()
|
||||
// force the IOB to 0 if over DIA hours have passed
|
||||
if (t < td) {
|
||||
|
@ -86,19 +83,21 @@ abstract class InsulinOrefBasePlugin(
|
|||
return result
|
||||
}
|
||||
|
||||
override fun getComment(): String {
|
||||
var comment = commentStandardText()
|
||||
val userDia = userDefinedDia
|
||||
if (userDia < MIN_DIA) {
|
||||
comment += "\n" + resourceHelper.gs(R.string.dia_too_short, userDia, MIN_DIA)
|
||||
override val comment
|
||||
get(): String {
|
||||
var comment = commentStandardText()
|
||||
val userDia = userDefinedDia
|
||||
if (userDia < MIN_DIA) {
|
||||
comment += "\n" + resourceHelper.gs(R.string.dia_too_short, userDia, MIN_DIA)
|
||||
}
|
||||
return comment
|
||||
}
|
||||
return comment
|
||||
}
|
||||
|
||||
abstract val peak: Int
|
||||
abstract fun commentStandardText(): String
|
||||
|
||||
companion object {
|
||||
|
||||
const val MIN_DIA = 5.0
|
||||
}
|
||||
}
|
|
@ -3,11 +3,14 @@ package info.nightscout.androidaps.plugins.insulin
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.utils.extensions.storeInt
|
||||
import info.nightscout.androidaps.utils.extensions.putInt
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
@ -23,12 +26,13 @@ class InsulinOrefFreePeakPlugin @Inject constructor(
|
|||
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||
) : InsulinOrefBasePlugin(injector, resourceHelper, profileFunction, rxBus, aapsLogger) {
|
||||
|
||||
override fun getId(): Int {
|
||||
return InsulinInterface.OREF_FREE_PEAK
|
||||
}
|
||||
override val id get(): InsulinInterface.InsulinType = InsulinInterface.InsulinType.OREF_FREE_PEAK
|
||||
|
||||
override fun getFriendlyName(): String {
|
||||
return resourceHelper.gs(R.string.free_peak_oref)
|
||||
override val friendlyName get(): String = resourceHelper.gs(R.string.free_peak_oref)
|
||||
|
||||
override fun configuration(): JSONObject = JSONObject().putInt(R.string.key_insulin_oref_peak, sp, resourceHelper)
|
||||
override fun applyConfiguration(configuration: JSONObject) {
|
||||
configuration.storeInt(R.string.key_insulin_oref_peak, sp, resourceHelper)
|
||||
}
|
||||
|
||||
override fun commentStandardText(): String {
|
||||
|
@ -39,6 +43,7 @@ class InsulinOrefFreePeakPlugin @Inject constructor(
|
|||
get() = sp.getInt(R.string.key_insulin_oref_peak, DEFAULT_PEAK)
|
||||
|
||||
companion object {
|
||||
|
||||
private const val DEFAULT_PEAK = 75
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@ package info.nightscout.androidaps.plugins.insulin
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
@ -21,18 +22,13 @@ class InsulinOrefRapidActingPlugin @Inject constructor(
|
|||
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||
) : InsulinOrefBasePlugin(injector, resourceHelper, profileFunction, rxBus, aapsLogger) {
|
||||
|
||||
override val id get(): InsulinInterface.InsulinType = InsulinInterface.InsulinType.OREF_RAPID_ACTING
|
||||
override val friendlyName get(): String = resourceHelper.gs(R.string.rapid_acting_oref)
|
||||
|
||||
override fun getId(): Int {
|
||||
return InsulinInterface.OREF_RAPID_ACTING
|
||||
}
|
||||
override fun configuration(): JSONObject = JSONObject()
|
||||
override fun applyConfiguration(configuration: JSONObject) {}
|
||||
|
||||
override fun getFriendlyName(): String {
|
||||
return resourceHelper.gs(R.string.rapid_acting_oref)
|
||||
}
|
||||
|
||||
override fun commentStandardText(): String {
|
||||
return resourceHelper.gs(R.string.fastactinginsulincomment)
|
||||
}
|
||||
override fun commentStandardText(): String = resourceHelper.gs(R.string.fastactinginsulincomment)
|
||||
|
||||
override val peak = 75
|
||||
|
||||
|
@ -41,5 +37,6 @@ class InsulinOrefRapidActingPlugin @Inject constructor(
|
|||
.pluginName(R.string.rapid_acting_oref)
|
||||
.description(R.string.description_insulin_rapid)
|
||||
.setDefault()
|
||||
.enableByDefault(true)
|
||||
}
|
||||
}
|
|
@ -3,10 +3,11 @@ package info.nightscout.androidaps.plugins.insulin
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
@ -21,10 +22,11 @@ class InsulinOrefUltraRapidActingPlugin @Inject constructor(
|
|||
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||
) : InsulinOrefBasePlugin(injector, resourceHelper, profileFunction, rxBus, aapsLogger) {
|
||||
|
||||
override val id get(): InsulinInterface.InsulinType = InsulinInterface.InsulinType.OREF_ULTRA_RAPID_ACTING
|
||||
override val friendlyName get(): String = resourceHelper.gs(R.string.ultrarapid_oref)
|
||||
|
||||
override fun getId(): Int = InsulinInterface.OREF_ULTRA_RAPID_ACTING
|
||||
|
||||
override fun getFriendlyName(): String = resourceHelper.gs(R.string.ultrarapid_oref)
|
||||
override fun configuration(): JSONObject = JSONObject()
|
||||
override fun applyConfiguration(configuration: JSONObject) {}
|
||||
|
||||
override fun commentStandardText(): String = resourceHelper.gs(R.string.ultrafastactinginsulincomment)
|
||||
|
||||
|
@ -34,6 +36,5 @@ class InsulinOrefUltraRapidActingPlugin @Inject constructor(
|
|||
pluginDescription
|
||||
.pluginName(R.string.ultrarapid_oref)
|
||||
.description(R.string.description_insulin_ultra_rapid)
|
||||
.enableByDefault(true)
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@ public class GlucoseStatus {
|
|||
@Inject public AAPSLogger aapsLogger;
|
||||
@Inject public IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
||||
|
||||
private HasAndroidInjector injector;
|
||||
private final HasAndroidInjector injector;
|
||||
|
||||
public double glucose = 0d;
|
||||
public double noise = 0d;
|
||||
|
|
|
@ -72,7 +72,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
|
|||
private final FabricPrivacy fabricPrivacy;
|
||||
private final DateUtil dateUtil;
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
private LongSparseArray<IobTotal> iobTable = new LongSparseArray<>(); // oldest at index 0
|
||||
private LongSparseArray<IobTotal> absIobTable = new LongSparseArray<>(); // oldest at index 0, absolute insulin in the body
|
||||
|
|
|
@ -73,10 +73,10 @@ public class IobCobOref1Thread extends Thread {
|
|||
private final HasAndroidInjector injector;
|
||||
private final IobCobCalculatorPlugin iobCobCalculatorPlugin; // cannot be injected : HistoryBrowser uses different instance
|
||||
private final TreatmentsPlugin treatmentsPlugin; // cannot be injected : HistoryBrowser uses different instance
|
||||
private boolean bgDataReload;
|
||||
private boolean limitDataToOldestAvailable;
|
||||
private String from;
|
||||
private long end;
|
||||
private final boolean bgDataReload;
|
||||
private final boolean limitDataToOldestAvailable;
|
||||
private final String from;
|
||||
private final long end;
|
||||
|
||||
private PowerManager.WakeLock mWakeLock;
|
||||
|
||||
|
@ -300,10 +300,7 @@ public class IobCobOref1Thread extends Thread {
|
|||
|
||||
// If mealCOB is zero but all deviations since hitting COB=0 are positive, exclude from autosens
|
||||
if (autosensData.cob > 0 || autosensData.absorbing || autosensData.mealCarbs > 0) {
|
||||
if (deviation > 0)
|
||||
autosensData.absorbing = true;
|
||||
else
|
||||
autosensData.absorbing = false;
|
||||
autosensData.absorbing = deviation > 0;
|
||||
// stop excluding positive deviations as soon as mealCOB=0 if meal has been absorbing for >5h
|
||||
if (autosensData.mealStartCounter > 60 && autosensData.cob < 0.5) {
|
||||
autosensData.absorbing = false;
|
||||
|
@ -329,10 +326,7 @@ public class IobCobOref1Thread extends Thread {
|
|||
//if (iob.iob > currentBasal || uam ) {
|
||||
if (iob.iob > 2 * currentBasal || autosensData.uam || autosensData.mealStartCounter < 9) {
|
||||
autosensData.mealStartCounter++;
|
||||
if (deviation > 0)
|
||||
autosensData.uam = true;
|
||||
else
|
||||
autosensData.uam = false;
|
||||
autosensData.uam = deviation > 0;
|
||||
if (!autosensData.type.equals("uam")) {
|
||||
// process.stderr.write("u(");
|
||||
}
|
||||
|
|
|
@ -70,10 +70,10 @@ public class IobCobThread extends Thread {
|
|||
private final HasAndroidInjector injector;
|
||||
private final IobCobCalculatorPlugin iobCobCalculatorPlugin; // cannot be injected : HistoryBrowser uses different instance
|
||||
private final TreatmentsPlugin treatmentsPlugin; // cannot be injected : HistoryBrowser uses different instance
|
||||
private boolean bgDataReload;
|
||||
private boolean limitDataToOldestAvailable;
|
||||
private String from;
|
||||
private long end;
|
||||
private final boolean bgDataReload;
|
||||
private final boolean limitDataToOldestAvailable;
|
||||
private final String from;
|
||||
private final long end;
|
||||
|
||||
private PowerManager.WakeLock mWakeLock;
|
||||
|
||||
|
|
|
@ -106,9 +106,9 @@ class LocalProfileFragment : DaggerFragment() {
|
|||
localprofile_name.removeTextChangedListener(textWatch)
|
||||
localprofile_name.setText(currentProfile.name)
|
||||
localprofile_name.addTextChangedListener(textWatch)
|
||||
localprofile_dia.setParams(currentProfile.dia, hardLimits.MINDIA, hardLimits.MAXDIA, 0.1, DecimalFormat("0.0"), false, localprofile_save, textWatch)
|
||||
localprofile_dia.setParams(currentProfile.dia, hardLimits.minDia(), hardLimits.maxDia(), 0.1, DecimalFormat("0.0"), false, localprofile_save, textWatch)
|
||||
localprofile_dia.tag = "LP_DIA"
|
||||
TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_ic, "IC", resourceHelper.gs(R.string.ic_label), currentProfile.ic, null, hardLimits.MINIC, hardLimits.MAXIC, 0.1, DecimalFormat("0.0"), save)
|
||||
TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_ic, "IC", resourceHelper.gs(R.string.ic_label), currentProfile.ic, null, hardLimits.minIC(), hardLimits.maxIC(), 0.1, DecimalFormat("0.0"), save)
|
||||
basalView = TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_basal, "BASAL", resourceHelper.gs(R.string.basal_label) + ": " + sumLabel(), currentProfile.basal, null, pumpDescription.basalMinimumRate, 10.0, 0.01, DecimalFormat("0.00"), save)
|
||||
if (units == Constants.MGDL) {
|
||||
TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_isf, "ISF", resourceHelper.gs(R.string.isf_label), currentProfile.isf, null, hardLimits.MINISF, hardLimits.MAXISF, 1.0, DecimalFormat("0"), save)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.profile.local
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.R
|
||||
|
@ -93,7 +93,7 @@ class LocalProfilePlugin @Inject constructor(
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
fun storeSettings(activity: Activity? = null) {
|
||||
fun storeSettings(activity: FragmentActivity? = null) {
|
||||
for (i in 0 until numOfProfiles) {
|
||||
profiles[i].run {
|
||||
val localProfileNumbered = Constants.LOCAL_PROFILE + "_" + i + "_"
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue