forgotten namespace

This commit is contained in:
Milos Kozak 2023-09-27 12:32:47 +02:00
parent 9d96219c67
commit 87cd4b354f
114 changed files with 599 additions and 600 deletions

View file

@ -477,7 +477,7 @@ class MainActivity : DaggerAppCompatActivityWithResult() {
FirebaseCrashlytics.getInstance().setCustomKey("Remote", remote) FirebaseCrashlytics.getInstance().setCustomKey("Remote", remote)
FirebaseCrashlytics.getInstance().setCustomKey("Committed", BuildConfig.COMMITTED) FirebaseCrashlytics.getInstance().setCustomKey("Committed", BuildConfig.COMMITTED)
FirebaseCrashlytics.getInstance().setCustomKey("Hash", hashes[0]) FirebaseCrashlytics.getInstance().setCustomKey("Hash", hashes[0])
FirebaseCrashlytics.getInstance().setCustomKey("Email", sp.getString(info.nightscout.core.utils.R.string.key_email_for_crash_report, "")) FirebaseCrashlytics.getInstance().setCustomKey("Email", sp.getString(app.aaps.core.utils.R.string.key_email_for_crash_report, ""))
} }
/** /**
@ -488,7 +488,7 @@ class MainActivity : DaggerAppCompatActivityWithResult() {
val passwordReset = File(fileListProvider.ensureExtraDirExists(), "PasswordReset") val passwordReset = File(fileListProvider.ensureExtraDirExists(), "PasswordReset")
if (passwordReset.exists()) { if (passwordReset.exists()) {
val sn = activePlugin.activePump.serialNumber() val sn = activePlugin.activePump.serialNumber()
sp.putString(info.nightscout.core.utils.R.string.key_master_password, cryptoUtil.hashPassword(sn)) sp.putString(app.aaps.core.utils.R.string.key_master_password, cryptoUtil.hashPassword(sn))
passwordReset.delete() passwordReset.delete()
ToastUtils.okToast(context, context.getString(app.aaps.core.ui.R.string.password_set)) ToastUtils.okToast(context, context.getString(app.aaps.core.ui.R.string.password_set))
} }

View file

@ -125,7 +125,7 @@ class MainApp : DaggerApplication() {
handler.postDelayed( handler.postDelayed(
{ {
// check if identification is set // check if identification is set
if (config.isDev() && sp.getStringOrNull(info.nightscout.core.utils.R.string.key_email_for_crash_report, null).isNullOrBlank()) if (config.isDev() && sp.getStringOrNull(app.aaps.core.utils.R.string.key_email_for_crash_report, null).isNullOrBlank())
notificationStore.add(Notification(Notification.IDENTIFICATION_NOT_SET, rh.get().gs(R.string.identification_not_set), Notification.INFO)) notificationStore.add(Notification(Notification.IDENTIFICATION_NOT_SET, rh.get().gs(R.string.identification_not_set), Notification.INFO))
// log version // log version
disposable += repository.runTransaction(VersionChangeTransaction(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, gitRemote, commitHash)).subscribe() disposable += repository.runTransaction(VersionChangeTransaction(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, gitRemote, commitHash)).subscribe()

View file

@ -246,11 +246,11 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
if (key == rh.gs(app.aaps.plugins.main.R.string.key_short_tabtitles)) { if (key == rh.gs(app.aaps.plugins.main.R.string.key_short_tabtitles)) {
rxBus.send(EventRebuildTabs()) rxBus.send(EventRebuildTabs())
} }
if (key == rh.gs(info.nightscout.core.utils.R.string.key_units)) { if (key == rh.gs(app.aaps.core.utils.R.string.key_units)) {
activity?.recreate() activity?.recreate()
return return
} }
if (key == rh.gs(info.nightscout.core.utils.R.string.key_use_autosens) && sp.getBoolean(info.nightscout.core.utils.R.string.key_use_autosens, false)) { if (key == rh.gs(app.aaps.core.utils.R.string.key_use_autosens) && sp.getBoolean(app.aaps.core.utils.R.string.key_use_autosens, false)) {
activity?.let { activity?.let {
OKDialog.show(it, rh.gs(app.aaps.plugins.configuration.R.string.configbuilder_sensitivity), rh.gs(R.string.sensitivity_warning)) OKDialog.show(it, rh.gs(app.aaps.plugins.configuration.R.string.configbuilder_sensitivity), rh.gs(R.string.sensitivity_warning))
} }
@ -269,10 +269,10 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
private fun checkForBiometricFallback(key: String) { private fun checkForBiometricFallback(key: String) {
// Biometric protection activated without set master password // Biometric protection activated without set master password
if ((rh.gs(info.nightscout.core.utils.R.string.key_settings_protection) == key || if ((rh.gs(app.aaps.core.utils.R.string.key_settings_protection) == key ||
rh.gs(info.nightscout.core.utils.R.string.key_application_protection) == key || rh.gs(app.aaps.core.utils.R.string.key_application_protection) == key ||
rh.gs(info.nightscout.core.utils.R.string.key_bolus_protection) == key) && rh.gs(app.aaps.core.utils.R.string.key_bolus_protection) == key) &&
sp.getString(info.nightscout.core.utils.R.string.key_master_password, "") == "" && sp.getString(app.aaps.core.utils.R.string.key_master_password, "") == "" &&
sp.getInt(key, NONE.ordinal) == BIOMETRIC.ordinal sp.getInt(key, NONE.ordinal) == BIOMETRIC.ordinal
) { ) {
activity?.let { activity?.let {
@ -288,10 +288,10 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
} }
// Master password erased with activated Biometric protection // Master password erased with activated Biometric protection
val isBiometricActivated = sp.getInt(info.nightscout.core.utils.R.string.key_settings_protection, NONE.ordinal) == BIOMETRIC.ordinal || val isBiometricActivated = sp.getInt(app.aaps.core.utils.R.string.key_settings_protection, NONE.ordinal) == BIOMETRIC.ordinal ||
sp.getInt(info.nightscout.core.utils.R.string.key_application_protection, NONE.ordinal) == BIOMETRIC.ordinal || sp.getInt(app.aaps.core.utils.R.string.key_application_protection, NONE.ordinal) == BIOMETRIC.ordinal ||
sp.getInt(info.nightscout.core.utils.R.string.key_bolus_protection, NONE.ordinal) == BIOMETRIC.ordinal sp.getInt(app.aaps.core.utils.R.string.key_bolus_protection, NONE.ordinal) == BIOMETRIC.ordinal
if (rh.gs(info.nightscout.core.utils.R.string.key_master_password) == key && sp.getString(key, "") == "" && isBiometricActivated) { if (rh.gs(app.aaps.core.utils.R.string.key_master_password) == key && sp.getString(key, "") == "" && isBiometricActivated) {
activity?.let { activity?.let {
val title = rh.gs(app.aaps.core.ui.R.string.unsecure_fallback_biometric) val title = rh.gs(app.aaps.core.ui.R.string.unsecure_fallback_biometric)
val message = rh.gs(app.aaps.core.ui.R.string.unsecure_fallback_descriotion_biometric) val message = rh.gs(app.aaps.core.ui.R.string.unsecure_fallback_descriotion_biometric)
@ -324,11 +324,11 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
private fun adjustUnitDependentPrefs(pref: Preference) { // convert preferences values to current units private fun adjustUnitDependentPrefs(pref: Preference) { // convert preferences values to current units
val unitDependent = arrayOf( val unitDependent = arrayOf(
rh.gs(info.nightscout.core.utils.R.string.key_hypo_target), rh.gs(app.aaps.core.utils.R.string.key_hypo_target),
rh.gs(info.nightscout.core.utils.R.string.key_activity_target), rh.gs(app.aaps.core.utils.R.string.key_activity_target),
rh.gs(info.nightscout.core.utils.R.string.key_eatingsoon_target), rh.gs(app.aaps.core.utils.R.string.key_eatingsoon_target),
rh.gs(info.nightscout.core.utils.R.string.key_high_mark), rh.gs(app.aaps.core.utils.R.string.key_high_mark),
rh.gs(info.nightscout.core.utils.R.string.key_low_mark) rh.gs(app.aaps.core.utils.R.string.key_low_mark)
) )
if (unitDependent.toList().contains(pref.key) && pref is EditTextPreference) { if (unitDependent.toList().contains(pref.key) && pref is EditTextPreference) {
val converted = profileUtil.valueInCurrentUnitsDetect(SafeParse.stringToDouble(pref.text)) val converted = profileUtil.valueInCurrentUnitsDetect(SafeParse.stringToDouble(pref.text))
@ -359,29 +359,29 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
if (pref is ListPreference) { if (pref is ListPreference) {
pref.setSummary(pref.entry) pref.setSummary(pref.entry)
// Preferences // Preferences
if (pref.getKey() == rh.gs(info.nightscout.core.utils.R.string.key_settings_protection)) { if (pref.getKey() == rh.gs(app.aaps.core.utils.R.string.key_settings_protection)) {
val pass: Preference? = findPreference(rh.gs(info.nightscout.core.utils.R.string.key_settings_password)) val pass: Preference? = findPreference(rh.gs(app.aaps.core.utils.R.string.key_settings_password))
val usePassword = pref.value == CUSTOM_PASSWORD.ordinal.toString() val usePassword = pref.value == CUSTOM_PASSWORD.ordinal.toString()
pass?.let { it.isVisible = usePassword } pass?.let { it.isVisible = usePassword }
val pin: Preference? = findPreference(rh.gs(info.nightscout.core.utils.R.string.key_settings_pin)) val pin: Preference? = findPreference(rh.gs(app.aaps.core.utils.R.string.key_settings_pin))
val usePin = pref.value == CUSTOM_PIN.ordinal.toString() val usePin = pref.value == CUSTOM_PIN.ordinal.toString()
pin?.let { it.isVisible = usePin } pin?.let { it.isVisible = usePin }
} }
// Application // Application
if (pref.getKey() == rh.gs(info.nightscout.core.utils.R.string.key_application_protection)) { if (pref.getKey() == rh.gs(app.aaps.core.utils.R.string.key_application_protection)) {
val pass: Preference? = findPreference(rh.gs(info.nightscout.core.utils.R.string.key_application_password)) val pass: Preference? = findPreference(rh.gs(app.aaps.core.utils.R.string.key_application_password))
val usePassword = pref.value == CUSTOM_PASSWORD.ordinal.toString() val usePassword = pref.value == CUSTOM_PASSWORD.ordinal.toString()
pass?.let { it.isVisible = usePassword } pass?.let { it.isVisible = usePassword }
val pin: Preference? = findPreference(rh.gs(info.nightscout.core.utils.R.string.key_application_pin)) val pin: Preference? = findPreference(rh.gs(app.aaps.core.utils.R.string.key_application_pin))
val usePin = pref.value == CUSTOM_PIN.ordinal.toString() val usePin = pref.value == CUSTOM_PIN.ordinal.toString()
pin?.let { it.isVisible = usePin } pin?.let { it.isVisible = usePin }
} }
// Bolus // Bolus
if (pref.getKey() == rh.gs(info.nightscout.core.utils.R.string.key_bolus_protection)) { if (pref.getKey() == rh.gs(app.aaps.core.utils.R.string.key_bolus_protection)) {
val pass: Preference? = findPreference(rh.gs(info.nightscout.core.utils.R.string.key_bolus_password)) val pass: Preference? = findPreference(rh.gs(app.aaps.core.utils.R.string.key_bolus_password))
val usePassword = pref.value == CUSTOM_PASSWORD.ordinal.toString() val usePassword = pref.value == CUSTOM_PASSWORD.ordinal.toString()
pass?.let { it.isVisible = usePassword } pass?.let { it.isVisible = usePassword }
val pin: Preference? = findPreference(rh.gs(info.nightscout.core.utils.R.string.key_bolus_pin)) val pin: Preference? = findPreference(rh.gs(app.aaps.core.utils.R.string.key_bolus_pin))
val usePin = pref.value == CUSTOM_PIN.ordinal.toString() val usePin = pref.value == CUSTOM_PIN.ordinal.toString()
pin?.let { it.isVisible = usePin } pin?.let { it.isVisible = usePin }
} }
@ -399,13 +399,13 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
} }
val hmacPasswords = arrayOf( val hmacPasswords = arrayOf(
rh.gs(info.nightscout.core.utils.R.string.key_bolus_password), rh.gs(app.aaps.core.utils.R.string.key_bolus_password),
rh.gs(info.nightscout.core.utils.R.string.key_master_password), rh.gs(app.aaps.core.utils.R.string.key_master_password),
rh.gs(info.nightscout.core.utils.R.string.key_application_password), rh.gs(app.aaps.core.utils.R.string.key_application_password),
rh.gs(info.nightscout.core.utils.R.string.key_settings_password), rh.gs(app.aaps.core.utils.R.string.key_settings_password),
rh.gs(info.nightscout.core.utils.R.string.key_bolus_pin), rh.gs(app.aaps.core.utils.R.string.key_bolus_pin),
rh.gs(info.nightscout.core.utils.R.string.key_application_pin), rh.gs(app.aaps.core.utils.R.string.key_application_pin),
rh.gs(info.nightscout.core.utils.R.string.key_settings_pin) rh.gs(app.aaps.core.utils.R.string.key_settings_pin)
) )
if (pref is Preference && (pref.key != null) && (hmacPasswords.contains(pref.key))) { if (pref is Preference && (pref.key != null) && (hmacPasswords.contains(pref.key))) {
@ -442,40 +442,40 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
override fun onPreferenceTreeClick(preference: Preference): Boolean = override fun onPreferenceTreeClick(preference: Preference): Boolean =
context?.let { context -> context?.let { context ->
when (preference.key) { when (preference.key) {
rh.gs(info.nightscout.core.utils.R.string.key_master_password) -> { rh.gs(app.aaps.core.utils.R.string.key_master_password) -> {
passwordCheck.queryPassword(context, app.aaps.plugins.configuration.R.string.current_master_password, info.nightscout.core.utils.R.string.key_master_password, { passwordCheck.queryPassword(context, app.aaps.plugins.configuration.R.string.current_master_password, app.aaps.core.utils.R.string.key_master_password, {
passwordCheck.setPassword(context, app.aaps.core.ui.R.string.master_password, info.nightscout.core.utils.R.string.key_master_password) passwordCheck.setPassword(context, app.aaps.core.ui.R.string.master_password, app.aaps.core.utils.R.string.key_master_password)
}) })
true true
} }
rh.gs(info.nightscout.core.utils.R.string.key_settings_password) -> { rh.gs(app.aaps.core.utils.R.string.key_settings_password) -> {
passwordCheck.setPassword(context, app.aaps.core.ui.R.string.settings_password, info.nightscout.core.utils.R.string.key_settings_password) passwordCheck.setPassword(context, app.aaps.core.ui.R.string.settings_password, app.aaps.core.utils.R.string.key_settings_password)
true true
} }
rh.gs(info.nightscout.core.utils.R.string.key_bolus_password) -> { rh.gs(app.aaps.core.utils.R.string.key_bolus_password) -> {
passwordCheck.setPassword(context, app.aaps.core.ui.R.string.bolus_password, info.nightscout.core.utils.R.string.key_bolus_password) passwordCheck.setPassword(context, app.aaps.core.ui.R.string.bolus_password, app.aaps.core.utils.R.string.key_bolus_password)
true true
} }
rh.gs(info.nightscout.core.utils.R.string.key_application_password) -> { rh.gs(app.aaps.core.utils.R.string.key_application_password) -> {
passwordCheck.setPassword(context, app.aaps.core.ui.R.string.application_password, info.nightscout.core.utils.R.string.key_application_password) passwordCheck.setPassword(context, app.aaps.core.ui.R.string.application_password, app.aaps.core.utils.R.string.key_application_password)
true true
} }
rh.gs(info.nightscout.core.utils.R.string.key_settings_pin) -> { rh.gs(app.aaps.core.utils.R.string.key_settings_pin) -> {
passwordCheck.setPassword(context, app.aaps.core.ui.R.string.settings_pin, info.nightscout.core.utils.R.string.key_settings_pin, pinInput = true) passwordCheck.setPassword(context, app.aaps.core.ui.R.string.settings_pin, app.aaps.core.utils.R.string.key_settings_pin, pinInput = true)
true true
} }
rh.gs(info.nightscout.core.utils.R.string.key_bolus_pin) -> { rh.gs(app.aaps.core.utils.R.string.key_bolus_pin) -> {
passwordCheck.setPassword(context, app.aaps.core.ui.R.string.bolus_pin, info.nightscout.core.utils.R.string.key_bolus_pin, pinInput = true) passwordCheck.setPassword(context, app.aaps.core.ui.R.string.bolus_pin, app.aaps.core.utils.R.string.key_bolus_pin, pinInput = true)
true true
} }
rh.gs(info.nightscout.core.utils.R.string.key_application_pin) -> { rh.gs(app.aaps.core.utils.R.string.key_application_pin) -> {
passwordCheck.setPassword(context, app.aaps.core.ui.R.string.application_pin, info.nightscout.core.utils.R.string.key_application_pin, pinInput = true) passwordCheck.setPassword(context, app.aaps.core.ui.R.string.application_pin, app.aaps.core.utils.R.string.key_application_pin, pinInput = true)
true true
} }
// NSClient copy settings // NSClient copy settings

View file

@ -17,7 +17,7 @@ class QuickWizard @Inject constructor(
private var storage = JSONArray() private var storage = JSONArray()
init { init {
setData(JSONArray(sp.getString(info.nightscout.core.utils.R.string.key_quickwizard, "[]"))) setData(JSONArray(sp.getString(app.aaps.core.utils.R.string.key_quickwizard, "[]")))
setGuidsForOldEntries() setGuidsForOldEntries()
} }
@ -45,7 +45,7 @@ class QuickWizard @Inject constructor(
} }
fun save() { fun save() {
sp.putString(info.nightscout.core.utils.R.string.key_quickwizard, storage.toString()) sp.putString(app.aaps.core.utils.R.string.key_quickwizard, storage.toString())
} }
fun size(): Int = storage.length() fun size(): Int = storage.length()

View file

@ -137,7 +137,7 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec
} }
// SuperBolus // SuperBolus
var superBolus = false var superBolus = false
if (useSuperBolus() == YES && sp.getBoolean(info.nightscout.core.utils.R.string.key_usesuperbolus, false)) { if (useSuperBolus() == YES && sp.getBoolean(app.aaps.core.utils.R.string.key_usesuperbolus, false)) {
superBolus = true superBolus = true
} }
if (loop.isEnabled() && loop.isSuperBolus) superBolus = false if (loop.isEnabled() && loop.isSuperBolus) superBolus = false
@ -151,7 +151,7 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec
} else if (useTrend() == NEGATIVE_ONLY && glucoseStatus != null && glucoseStatus.shortAvgDelta < 0) { } else if (useTrend() == NEGATIVE_ONLY && glucoseStatus != null && glucoseStatus.shortAvgDelta < 0) {
trend = true trend = true
} }
val percentage = if (usePercentage() == DEFAULT) sp.getInt(info.nightscout.core.utils.R.string.key_boluswizard_percentage, 100) else percentage() val percentage = if (usePercentage() == DEFAULT) sp.getInt(app.aaps.core.utils.R.string.key_boluswizard_percentage, 100) else percentage()
return BolusWizard(injector).doCalc( return BolusWizard(injector).doCalc(
profile, profile,
profileName, profileName,

View file

@ -48,7 +48,7 @@ class QuickWizardTest : TestBase() {
@BeforeEach @BeforeEach
fun setup() { fun setup() {
`when`(sp.getString(info.nightscout.core.utils.R.string.key_quickwizard, "[]")).thenReturn("[]") `when`(sp.getString(app.aaps.core.utils.R.string.key_quickwizard, "[]")).thenReturn("[]")
quickWizard = QuickWizard(sp, injector) quickWizard = QuickWizard(sp, injector)
} }

View file

@ -13,7 +13,7 @@ apply from: "${project.rootDir}/core/main/jacoco_global.gradle"
android { android {
namespace 'info.nightscout.core.utils' namespace 'app.aaps.core.utils'
} }
dependencies { dependencies {

View file

@ -51,18 +51,18 @@ class LocalAlertUtilsImpl @Inject constructor(
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
private fun missedReadingsThreshold(): Long { private fun missedReadingsThreshold(): Long {
return T.mins(sp.getInt(info.nightscout.core.utils.R.string.key_missed_bg_readings_threshold_minutes, Constants.DEFAULT_MISSED_BG_READINGS_THRESHOLD_MINUTES).toLong()).msecs() return T.mins(sp.getInt(app.aaps.core.utils.R.string.key_missed_bg_readings_threshold_minutes, Constants.DEFAULT_MISSED_BG_READINGS_THRESHOLD_MINUTES).toLong()).msecs()
} }
private fun pumpUnreachableThreshold(): Long { private fun pumpUnreachableThreshold(): Long {
return T.mins(sp.getInt(info.nightscout.core.utils.R.string.key_pump_unreachable_threshold_minutes, Constants.DEFAULT_PUMP_UNREACHABLE_THRESHOLD_MINUTES).toLong()).msecs() return T.mins(sp.getInt(app.aaps.core.utils.R.string.key_pump_unreachable_threshold_minutes, Constants.DEFAULT_PUMP_UNREACHABLE_THRESHOLD_MINUTES).toLong()).msecs()
} }
override fun checkPumpUnreachableAlarm(lastConnection: Long, isStatusOutdated: Boolean, isDisconnected: Boolean) { override fun checkPumpUnreachableAlarm(lastConnection: Long, isStatusOutdated: Boolean, isDisconnected: Boolean) {
val alarmTimeoutExpired = isAlarmTimeoutExpired(lastConnection, pumpUnreachableThreshold()) val alarmTimeoutExpired = isAlarmTimeoutExpired(lastConnection, pumpUnreachableThreshold())
val nextAlarmOccurrenceReached = sp.getLong("nextPumpDisconnectedAlarm", 0L) < System.currentTimeMillis() val nextAlarmOccurrenceReached = sp.getLong("nextPumpDisconnectedAlarm", 0L) < System.currentTimeMillis()
if (config.APS && isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !isDisconnected) { if (config.APS && isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !isDisconnected) {
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_enable_pump_unreachable_alert, true)) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_enable_pump_unreachable_alert, true)) {
aapsLogger.debug(LTag.CORE, "Generating pump unreachable alarm. lastConnection: " + dateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated) aapsLogger.debug(LTag.CORE, "Generating pump unreachable alarm. lastConnection: " + dateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated)
sp.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold()) sp.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold())
rxBus.send(EventNewNotification(Notification(Notification.PUMP_UNREACHABLE, rh.gs(app.aaps.core.ui.R.string.pump_unreachable), Notification.URGENT).also { rxBus.send(EventNewNotification(Notification(Notification.PUMP_UNREACHABLE, rh.gs(app.aaps.core.ui.R.string.pump_unreachable), Notification.URGENT).also {
@ -70,10 +70,10 @@ class LocalAlertUtilsImpl @Inject constructor(
app.aaps.core.ui.R.raw.alarm app.aaps.core.ui.R.raw.alarm
})) }))
uel.log(Action.CAREPORTAL, Sources.Aaps, rh.gs(app.aaps.core.ui.R.string.pump_unreachable), ValueWithUnit.TherapyEventType(TherapyEvent.Type.ANNOUNCEMENT)) uel.log(Action.CAREPORTAL, Sources.Aaps, rh.gs(app.aaps.core.ui.R.string.pump_unreachable), ValueWithUnit.TherapyEventType(TherapyEvent.Type.ANNOUNCEMENT))
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_create_announcements_from_errors, true)) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_create_announcements_from_errors, true))
disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(rh.gs(app.aaps.core.ui.R.string.pump_unreachable))).subscribe() disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(rh.gs(app.aaps.core.ui.R.string.pump_unreachable))).subscribe()
} }
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_smscommunicator_report_pump_unreachable, true)) if (sp.getBoolean(app.aaps.core.utils.R.string.key_smscommunicator_report_pump_unreachable, true))
smsCommunicator.sendNotificationToAllNumbers(rh.gs(app.aaps.core.ui.R.string.pump_unreachable)) smsCommunicator.sendNotificationToAllNumbers(rh.gs(app.aaps.core.ui.R.string.pump_unreachable))
} }
if (!isStatusOutdated && !alarmTimeoutExpired) rxBus.send(EventDismissNotification(Notification.PUMP_UNREACHABLE)) if (!isStatusOutdated && !alarmTimeoutExpired) rxBus.send(EventDismissNotification(Notification.PUMP_UNREACHABLE))
@ -123,7 +123,7 @@ class LocalAlertUtilsImpl @Inject constructor(
override fun checkStaleBGAlert() { override fun checkStaleBGAlert() {
val bgReadingWrapped = repository.getLastGlucoseValueWrapped().blockingGet() val bgReadingWrapped = repository.getLastGlucoseValueWrapped().blockingGet()
val bgReading = if (bgReadingWrapped is ValueWrapper.Existing) bgReadingWrapped.value else return val bgReading = if (bgReadingWrapped is ValueWrapper.Existing) bgReadingWrapped.value else return
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_enable_missed_bg_readings_alert, false) if (sp.getBoolean(app.aaps.core.utils.R.string.key_enable_missed_bg_readings_alert, false)
&& bgReading.timestamp + missedReadingsThreshold() < System.currentTimeMillis() && bgReading.timestamp + missedReadingsThreshold() < System.currentTimeMillis()
&& sp.getLong("nextMissedReadingsAlarm", 0L) < System.currentTimeMillis() && sp.getLong("nextMissedReadingsAlarm", 0L) < System.currentTimeMillis()
) { ) {
@ -132,7 +132,7 @@ class LocalAlertUtilsImpl @Inject constructor(
sp.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold()) sp.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold())
rxBus.send(EventNewNotification(n)) rxBus.send(EventNewNotification(n))
uel.log(Action.CAREPORTAL, Sources.Aaps, rh.gs(app.aaps.core.ui.R.string.missed_bg_readings), ValueWithUnit.TherapyEventType(TherapyEvent.Type.ANNOUNCEMENT)) uel.log(Action.CAREPORTAL, Sources.Aaps, rh.gs(app.aaps.core.ui.R.string.missed_bg_readings), ValueWithUnit.TherapyEventType(TherapyEvent.Type.ANNOUNCEMENT))
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_create_announcements_from_errors, true)) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_create_announcements_from_errors, true)) {
disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(n.text)).subscribe() disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(n.text)).subscribe()
} }
} else if (dateUtil.isOlderThan(bgReading.timestamp, 5).not()) { } else if (dateUtil.isOlderThan(bgReading.timestamp, 5).not()) {

View file

@ -108,7 +108,7 @@ class OverviewDataImpl @Inject constructor(
} }
override fun initRange() { override fun initRange() {
rangeToDisplay = sp.getInt(info.nightscout.core.utils.R.string.key_rangetodisplay, 6) rangeToDisplay = sp.getInt(app.aaps.core.utils.R.string.key_rangetodisplay, 6)
val calendar = Calendar.getInstance().also { val calendar = Calendar.getInstance().also {
it.timeInMillis = System.currentTimeMillis() it.timeInMillis = System.currentTimeMillis()

View file

@ -53,13 +53,13 @@ class DefaultValueHelperImpl @Inject constructor(
*/ */
override fun determineEatingSoonTT(): Double { override fun determineEatingSoonTT(): Double {
val units = profileUtil.units val units = profileUtil.units
var value = sp.getDouble(info.nightscout.core.utils.R.string.key_eatingsoon_target, getDefaultEatingSoonTT(units)) var value = sp.getDouble(app.aaps.core.utils.R.string.key_eatingsoon_target, getDefaultEatingSoonTT(units))
value = profileUtil.valueInCurrentUnitsDetect(value) value = profileUtil.valueInCurrentUnitsDetect(value)
return if (value > 0) value else getDefaultEatingSoonTT(units) return if (value > 0) value else getDefaultEatingSoonTT(units)
} }
override fun determineEatingSoonTTDuration(): Int { override fun determineEatingSoonTTDuration(): Int {
val value = sp.getInt(info.nightscout.core.utils.R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration) val value = sp.getInt(app.aaps.core.utils.R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration)
return if (value > 0) value else Constants.defaultEatingSoonTTDuration return if (value > 0) value else Constants.defaultEatingSoonTTDuration
} }
@ -70,13 +70,13 @@ class DefaultValueHelperImpl @Inject constructor(
*/ */
override fun determineActivityTT(): Double { override fun determineActivityTT(): Double {
val units = profileUtil.units val units = profileUtil.units
var value = sp.getDouble(info.nightscout.core.utils.R.string.key_activity_target, getDefaultActivityTT(units)) var value = sp.getDouble(app.aaps.core.utils.R.string.key_activity_target, getDefaultActivityTT(units))
value = profileUtil.valueInCurrentUnitsDetect(value) value = profileUtil.valueInCurrentUnitsDetect(value)
return if (value > 0) value else getDefaultActivityTT(units) return if (value > 0) value else getDefaultActivityTT(units)
} }
override fun determineActivityTTDuration(): Int { override fun determineActivityTTDuration(): Int {
val value = sp.getInt(info.nightscout.core.utils.R.string.key_activity_duration, Constants.defaultActivityTTDuration) val value = sp.getInt(app.aaps.core.utils.R.string.key_activity_duration, Constants.defaultActivityTTDuration)
return if (value > 0) value else Constants.defaultActivityTTDuration return if (value > 0) value else Constants.defaultActivityTTDuration
} }
@ -87,13 +87,13 @@ class DefaultValueHelperImpl @Inject constructor(
*/ */
override fun determineHypoTT(): Double { override fun determineHypoTT(): Double {
val units = profileUtil.units val units = profileUtil.units
var value = sp.getDouble(info.nightscout.core.utils.R.string.key_hypo_target, getDefaultHypoTT(units)) var value = sp.getDouble(app.aaps.core.utils.R.string.key_hypo_target, getDefaultHypoTT(units))
value = profileUtil.valueInCurrentUnitsDetect(value) value = profileUtil.valueInCurrentUnitsDetect(value)
return if (value > 0) value else getDefaultHypoTT(units) return if (value > 0) value else getDefaultHypoTT(units)
} }
override fun determineHypoTTDuration(): Int { override fun determineHypoTTDuration(): Int {
val value = sp.getInt(info.nightscout.core.utils.R.string.key_hypo_duration, Constants.defaultHypoTTDuration) val value = sp.getInt(app.aaps.core.utils.R.string.key_hypo_duration, Constants.defaultHypoTTDuration)
return if (value > 0) value else Constants.defaultHypoTTDuration return if (value > 0) value else Constants.defaultHypoTTDuration
} }
@ -101,14 +101,14 @@ class DefaultValueHelperImpl @Inject constructor(
override var bgTargetHigh = 180.0 override var bgTargetHigh = 180.0
override fun determineHighLine(): Double { override fun determineHighLine(): Double {
var highLineSetting = sp.getDouble(info.nightscout.core.utils.R.string.key_high_mark, bgTargetHigh) var highLineSetting = sp.getDouble(app.aaps.core.utils.R.string.key_high_mark, bgTargetHigh)
if (highLineSetting < 1) highLineSetting = Constants.HIGH_MARK if (highLineSetting < 1) highLineSetting = Constants.HIGH_MARK
highLineSetting = profileUtil.valueInCurrentUnitsDetect(highLineSetting) highLineSetting = profileUtil.valueInCurrentUnitsDetect(highLineSetting)
return highLineSetting return highLineSetting
} }
override fun determineLowLine(): Double { override fun determineLowLine(): Double {
var lowLineSetting = sp.getDouble(info.nightscout.core.utils.R.string.key_low_mark, bgTargetLow) var lowLineSetting = sp.getDouble(app.aaps.core.utils.R.string.key_low_mark, bgTargetLow)
if (lowLineSetting < 1) lowLineSetting = Constants.LOW_MARK if (lowLineSetting < 1) lowLineSetting = Constants.LOW_MARK
lowLineSetting = profileUtil.valueInCurrentUnitsDetect(lowLineSetting) lowLineSetting = profileUtil.valueInCurrentUnitsDetect(lowLineSetting)
return lowLineSetting return lowLineSetting

View file

@ -142,7 +142,7 @@ class ProfileFunctionImpl @Inject constructor(
} }
override fun getUnits(): GlucoseUnit = override fun getUnits(): GlucoseUnit =
if (sp.getString(info.nightscout.core.utils.R.string.key_units, GlucoseUnit.MGDL.asText) == GlucoseUnit.MGDL.asText) GlucoseUnit.MGDL if (sp.getString(app.aaps.core.utils.R.string.key_units, GlucoseUnit.MGDL.asText) == GlucoseUnit.MGDL.asText) GlucoseUnit.MGDL
else GlucoseUnit.MMOL else GlucoseUnit.MMOL
override fun buildProfileSwitch(profileStore: ProfileStore, profileName: String, durationInMinutes: Int, percentage: Int, timeShiftInHours: Int, timestamp: Long): ProfileSwitch? { override fun buildProfileSwitch(profileStore: ProfileStore, profileName: String, durationInMinutes: Int, percentage: Int, timeShiftInHours: Int, timestamp: Long): ProfileSwitch? {

View file

@ -15,7 +15,7 @@ class ProfileUtilImpl @Inject constructor(
override val units: GlucoseUnit override val units: GlucoseUnit
get() = get() =
if (sp.getString(info.nightscout.core.utils.R.string.key_units, GlucoseUnit.MGDL.asText) == GlucoseUnit.MGDL.asText) GlucoseUnit.MGDL if (sp.getString(app.aaps.core.utils.R.string.key_units, GlucoseUnit.MGDL.asText) == GlucoseUnit.MGDL.asText) GlucoseUnit.MGDL
else GlucoseUnit.MMOL else GlucoseUnit.MMOL
override fun fromMgdlToUnits(valueInMgdl: Double, targetUnits: GlucoseUnit): Double = override fun fromMgdlToUnits(valueInMgdl: Double, targetUnits: GlucoseUnit): Double =

View file

@ -42,7 +42,7 @@ object BiometricCheck {
ToastUtils.errorToast(activity.baseContext, errString.toString()) ToastUtils.errorToast(activity.baseContext, errString.toString())
// fallback to master password // fallback to master password
runOnUiThread { runOnUiThread {
passwordCheck.queryPassword(activity, R.string.master_password, info.nightscout.core.utils.R.string.key_master_password, { ok?.run() }, { cancel?.run() }, { fail?.run() }) passwordCheck.queryPassword(activity, R.string.master_password, app.aaps.core.utils.R.string.key_master_password, { ok?.run() }, { cancel?.run() }, { fail?.run() })
} }
} }
@ -54,7 +54,7 @@ object BiometricCheck {
// no pin set // no pin set
// fallback to master password // fallback to master password
runOnUiThread { runOnUiThread {
passwordCheck.queryPassword(activity, R.string.master_password, info.nightscout.core.utils.R.string.key_master_password, { ok?.run() }, { cancel?.run() }, { fail?.run() }) passwordCheck.queryPassword(activity, R.string.master_password, app.aaps.core.utils.R.string.key_master_password, { ok?.run() }, { cancel?.run() }, { fail?.run() })
} }
} }
@ -63,7 +63,7 @@ object BiometricCheck {
ERROR_HW_NOT_PRESENT, ERROR_HW_NOT_PRESENT,
ERROR_NO_BIOMETRICS -> ERROR_NO_BIOMETRICS ->
runOnUiThread { runOnUiThread {
passwordCheck.queryPassword(activity, R.string.master_password, info.nightscout.core.utils.R.string.key_master_password, { ok?.run() }, { cancel?.run() }, { fail?.run() }) passwordCheck.queryPassword(activity, R.string.master_password, app.aaps.core.utils.R.string.key_master_password, { ok?.run() }, { cancel?.run() }, { fail?.run() })
} }
} }
} }

View file

@ -19,21 +19,21 @@ class ProtectionCheckImpl @Inject constructor(
private var lastAuthorization = mutableListOf(0L, 0L, 0L) private var lastAuthorization = mutableListOf(0L, 0L, 0L)
private val passwordsResourceIDs = listOf( private val passwordsResourceIDs = listOf(
info.nightscout.core.utils.R.string.key_settings_password, app.aaps.core.utils.R.string.key_settings_password,
info.nightscout.core.utils.R.string.key_application_password, app.aaps.core.utils.R.string.key_application_password,
info.nightscout.core.utils.R.string.key_bolus_password app.aaps.core.utils.R.string.key_bolus_password
) )
private val pinsResourceIDs = listOf( private val pinsResourceIDs = listOf(
info.nightscout.core.utils.R.string.key_settings_pin, app.aaps.core.utils.R.string.key_settings_pin,
info.nightscout.core.utils.R.string.key_application_pin, app.aaps.core.utils.R.string.key_application_pin,
info.nightscout.core.utils.R.string.key_bolus_pin app.aaps.core.utils.R.string.key_bolus_pin
) )
private val protectionTypeResourceIDs = listOf( private val protectionTypeResourceIDs = listOf(
info.nightscout.core.utils.R.string.key_settings_protection, app.aaps.core.utils.R.string.key_settings_protection,
info.nightscout.core.utils.R.string.key_application_protection, app.aaps.core.utils.R.string.key_application_protection,
info.nightscout.core.utils.R.string.key_bolus_protection app.aaps.core.utils.R.string.key_bolus_protection
) )
private val titlePassResourceIDs = listOf( private val titlePassResourceIDs = listOf(
@ -55,7 +55,7 @@ class ProtectionCheckImpl @Inject constructor(
return when (ProtectionCheck.ProtectionType.values()[sp.getInt(protectionTypeResourceIDs[protection.ordinal], ProtectionCheck.ProtectionType.NONE.ordinal)]) { return when (ProtectionCheck.ProtectionType.values()[sp.getInt(protectionTypeResourceIDs[protection.ordinal], ProtectionCheck.ProtectionType.NONE.ordinal)]) {
ProtectionCheck.ProtectionType.NONE -> false ProtectionCheck.ProtectionType.NONE -> false
ProtectionCheck.ProtectionType.BIOMETRIC -> true ProtectionCheck.ProtectionType.BIOMETRIC -> true
ProtectionCheck.ProtectionType.MASTER_PASSWORD -> sp.getString(info.nightscout.core.utils.R.string.key_master_password, "") != "" ProtectionCheck.ProtectionType.MASTER_PASSWORD -> sp.getString(app.aaps.core.utils.R.string.key_master_password, "") != ""
ProtectionCheck.ProtectionType.CUSTOM_PASSWORD -> sp.getString(passwordsResourceIDs[protection.ordinal], "") != "" ProtectionCheck.ProtectionType.CUSTOM_PASSWORD -> sp.getString(passwordsResourceIDs[protection.ordinal], "") != ""
ProtectionCheck.ProtectionType.CUSTOM_PIN -> sp.getString(pinsResourceIDs[protection.ordinal], "") != "" ProtectionCheck.ProtectionType.CUSTOM_PIN -> sp.getString(pinsResourceIDs[protection.ordinal], "") != ""
} }
@ -66,7 +66,7 @@ class ProtectionCheckImpl @Inject constructor(
} }
private fun activeSession(protection: ProtectionCheck.Protection): Boolean { private fun activeSession(protection: ProtectionCheck.Protection): Boolean {
var timeout = TimeUnit.SECONDS.toMillis(sp.getInt(info.nightscout.core.utils.R.string.key_protection_timeout, 0).toLong()) var timeout = TimeUnit.SECONDS.toMillis(sp.getInt(app.aaps.core.utils.R.string.key_protection_timeout, 0).toLong())
// Default timeout to pass the resume check at start of an activity // Default timeout to pass the resume check at start of an activity
timeout = if (timeout < 1000) 1000 else timeout timeout = if (timeout < 1000) 1000 else timeout
val last = lastAuthorization[protection.ordinal] val last = lastAuthorization[protection.ordinal]
@ -96,7 +96,7 @@ class ProtectionCheckImpl @Inject constructor(
passwordCheck.queryPassword( passwordCheck.queryPassword(
activity, activity,
app.aaps.core.ui.R.string.master_password, app.aaps.core.ui.R.string.master_password,
info.nightscout.core.utils.R.string.key_master_password, app.aaps.core.utils.R.string.key_master_password,
{ onOk(protection); ok?.run() }, { onOk(protection); ok?.run() },
{ cancel?.run() }, { cancel?.run() },
{ fail?.run() }) { fail?.run() })

View file

@ -73,14 +73,14 @@ class PumpSyncImplementation @Inject constructor(
syncStopExtendedBolusWithPumpId(dateUtil.now(), dateUtil.now(), it.pumpType, it.pumpSerial) syncStopExtendedBolusWithPumpId(dateUtil.now(), dateUtil.now(), it.pumpType, it.pumpSerial)
} }
} }
sp.remove(info.nightscout.core.utils.R.string.key_active_pump_type) sp.remove(app.aaps.core.utils.R.string.key_active_pump_type)
sp.remove(info.nightscout.core.utils.R.string.key_active_pump_serial_number) sp.remove(app.aaps.core.utils.R.string.key_active_pump_serial_number)
sp.remove(info.nightscout.core.utils.R.string.key_active_pump_change_timestamp) sp.remove(app.aaps.core.utils.R.string.key_active_pump_change_timestamp)
} }
override fun verifyPumpIdentification(type: PumpType, serialNumber: String): Boolean { override fun verifyPumpIdentification(type: PumpType, serialNumber: String): Boolean {
val storedType = sp.getString(info.nightscout.core.utils.R.string.key_active_pump_type, "") val storedType = sp.getString(app.aaps.core.utils.R.string.key_active_pump_type, "")
val storedSerial = sp.getString(info.nightscout.core.utils.R.string.key_active_pump_serial_number, "") val storedSerial = sp.getString(app.aaps.core.utils.R.string.key_active_pump_serial_number, "")
if (activePlugin.activePump is VirtualPump) return true if (activePlugin.activePump is VirtualPump) return true
if (type.description == storedType && serialNumber == storedSerial) return true if (type.description == storedType && serialNumber == storedSerial) return true
aapsLogger.debug(LTag.PUMP, "verifyPumpIdentification failed for $type $serialNumber") aapsLogger.debug(LTag.PUMP, "verifyPumpIdentification failed for $type $serialNumber")
@ -96,16 +96,16 @@ class PumpSyncImplementation @Inject constructor(
* @return true if data is allowed * @return true if data is allowed
*/ */
private fun confirmActivePump(timestamp: Long, type: PumpType, serialNumber: String, showNotification: Boolean = true): Boolean { private fun confirmActivePump(timestamp: Long, type: PumpType, serialNumber: String, showNotification: Boolean = true): Boolean {
val storedType = sp.getString(info.nightscout.core.utils.R.string.key_active_pump_type, "") val storedType = sp.getString(app.aaps.core.utils.R.string.key_active_pump_type, "")
val storedSerial = sp.getString(info.nightscout.core.utils.R.string.key_active_pump_serial_number, "") val storedSerial = sp.getString(app.aaps.core.utils.R.string.key_active_pump_serial_number, "")
val storedTimestamp = sp.getLong(info.nightscout.core.utils.R.string.key_active_pump_change_timestamp, 0L) val storedTimestamp = sp.getLong(app.aaps.core.utils.R.string.key_active_pump_change_timestamp, 0L)
// If no value stored assume we start using new pump from now // If no value stored assume we start using new pump from now
if (storedType.isEmpty() || storedSerial.isEmpty()) { if (storedType.isEmpty() || storedSerial.isEmpty()) {
aapsLogger.debug(LTag.PUMP, "Registering new pump ${type.description} $serialNumber") aapsLogger.debug(LTag.PUMP, "Registering new pump ${type.description} $serialNumber")
sp.putString(info.nightscout.core.utils.R.string.key_active_pump_type, type.description) sp.putString(app.aaps.core.utils.R.string.key_active_pump_type, type.description)
sp.putString(info.nightscout.core.utils.R.string.key_active_pump_serial_number, serialNumber) sp.putString(app.aaps.core.utils.R.string.key_active_pump_serial_number, serialNumber)
sp.putLong(info.nightscout.core.utils.R.string.key_active_pump_change_timestamp, dateUtil.now()) // allow only data newer than register time (ie. ignore older history) sp.putLong(app.aaps.core.utils.R.string.key_active_pump_change_timestamp, dateUtil.now()) // allow only data newer than register time (ie. ignore older history)
return timestamp > dateUtil.now() - T.mins(1).msecs() // allow first record to be 1 min old return timestamp > dateUtil.now() - T.mins(1).msecs() // allow first record to be 1 min old
} }
@ -166,7 +166,7 @@ class PumpSyncImplementation @Inject constructor(
} }
else null, else null,
profile = profileFunction.getProfile(), profile = profileFunction.getProfile(),
serialNumber = sp.getString(info.nightscout.core.utils.R.string.key_active_pump_serial_number, "") serialNumber = sp.getString(app.aaps.core.utils.R.string.key_active_pump_serial_number, "")
) )
} }

View file

@ -68,13 +68,13 @@ class QueueThread internal constructor(
pump.stopConnecting() pump.stopConnecting()
//BLUETOOTH-WATCHDOG //BLUETOOTH-WATCHDOG
var watchdog = sp.getBoolean(info.nightscout.core.utils.R.string.key_btwatchdog, false) var watchdog = sp.getBoolean(app.aaps.core.utils.R.string.key_btwatchdog, false)
val lastWatchdog = sp.getLong(info.nightscout.core.utils.R.string.key_btwatchdog_lastbark, 0L) val lastWatchdog = sp.getLong(app.aaps.core.utils.R.string.key_btwatchdog_lastbark, 0L)
watchdog = watchdog && System.currentTimeMillis() - lastWatchdog > Constants.MIN_WATCHDOG_INTERVAL_IN_SECONDS * 1000 watchdog = watchdog && System.currentTimeMillis() - lastWatchdog > Constants.MIN_WATCHDOG_INTERVAL_IN_SECONDS * 1000
if (watchdog) { if (watchdog) {
aapsLogger.debug(LTag.PUMPQUEUE, "BT watchdog - toggling the phone bluetooth") aapsLogger.debug(LTag.PUMPQUEUE, "BT watchdog - toggling the phone bluetooth")
//write time //write time
sp.putLong(info.nightscout.core.utils.R.string.key_btwatchdog_lastbark, System.currentTimeMillis()) sp.putLong(app.aaps.core.utils.R.string.key_btwatchdog_lastbark, System.currentTimeMillis())
//toggle BT //toggle BT
pump.disconnect("watchdog") pump.disconnect("watchdog")
SystemClock.sleep(1000) SystemClock.sleep(1000)

View file

@ -64,12 +64,12 @@ class HardLimitsImpl @Inject constructor(
} }
private fun loadAge(): Int = when (sp.getString(info.nightscout.core.utils.R.string.key_age, "")) { private fun loadAge(): Int = when (sp.getString(app.aaps.core.utils.R.string.key_age, "")) {
rh.gs(info.nightscout.core.utils.R.string.key_child) -> CHILD rh.gs(app.aaps.core.utils.R.string.key_child) -> CHILD
rh.gs(info.nightscout.core.utils.R.string.key_teenage) -> TEENAGE rh.gs(app.aaps.core.utils.R.string.key_teenage) -> TEENAGE
rh.gs(info.nightscout.core.utils.R.string.key_adult) -> ADULT rh.gs(app.aaps.core.utils.R.string.key_adult) -> ADULT
rh.gs(info.nightscout.core.utils.R.string.key_resistantadult) -> RESISTANT_ADULT rh.gs(app.aaps.core.utils.R.string.key_resistantadult) -> RESISTANT_ADULT
rh.gs(info.nightscout.core.utils.R.string.key_pregnant) -> PREGNANT rh.gs(app.aaps.core.utils.R.string.key_pregnant) -> PREGNANT
else -> ADULT else -> ADULT
} }

View file

@ -7,11 +7,11 @@ import app.aaps.core.interfaces.logging.LTag
import app.aaps.core.interfaces.rx.weardata.EventData import app.aaps.core.interfaces.rx.weardata.EventData
import app.aaps.core.interfaces.sharedPreferences.SP import app.aaps.core.interfaces.sharedPreferences.SP
import app.aaps.core.interfaces.utils.fabric.FabricPrivacy import app.aaps.core.interfaces.utils.fabric.FabricPrivacy
import app.aaps.core.utils.R
import com.google.firebase.analytics.FirebaseAnalytics import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.analytics.ktx.analytics import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.crashlytics.FirebaseCrashlytics import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.google.firebase.ktx.Firebase import com.google.firebase.ktx.Firebase
import info.nightscout.core.utils.R
import java.io.ByteArrayInputStream import java.io.ByteArrayInputStream
import java.io.IOException import java.io.IOException
import java.io.ObjectInputStream import java.io.ObjectInputStream

View file

@ -322,7 +322,7 @@ open class APSResultObject @Inject constructor(val injector: HasAndroidInjector)
} }
} }
// report change bigger than 30% // report change bigger than 30%
var percentMinChangeChange = sp.getDouble(info.nightscout.core.utils.R.string.key_loop_openmode_min_change, 30.0) var percentMinChangeChange = sp.getDouble(app.aaps.core.utils.R.string.key_loop_openmode_min_change, 30.0)
percentMinChangeChange /= 100.0 percentMinChangeChange /= 100.0
val lowThreshold = 1 - percentMinChangeChange val lowThreshold = 1 - percentMinChangeChange
val highThreshold = 1 + percentMinChangeChange val highThreshold = 1 + percentMinChangeChange
@ -358,7 +358,7 @@ open class APSResultObject @Inject constructor(val injector: HasAndroidInjector)
} }
} }
// report change bigger than 30% // report change bigger than 30%
var percentMinChangeChange = sp.getDouble(info.nightscout.core.utils.R.string.key_loop_openmode_min_change, 30.0) var percentMinChangeChange = sp.getDouble(app.aaps.core.utils.R.string.key_loop_openmode_min_change, 30.0)
percentMinChangeChange /= 100.0 percentMinChangeChange /= 100.0
val lowThreshold = 1 - percentMinChangeChange val lowThreshold = 1 - percentMinChangeChange
val highThreshold = 1 + percentMinChangeChange val highThreshold = 1 + percentMinChangeChange

View file

@ -41,9 +41,9 @@ class AutotuneCore @Inject constructor(
val pumpCarbRatio = pumpProfile.ic val pumpCarbRatio = pumpProfile.ic
val pumpCSF = pumpISF / pumpCarbRatio val pumpCSF = pumpISF / pumpCarbRatio
// Autosens constraints // Autosens constraints
val autotuneMax = sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_max, 1.2) val autotuneMax = sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_autosens_max, 1.2)
val autotuneMin = sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_min, 0.7) val autotuneMin = sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_autosens_min, 0.7)
val min5minCarbImpact = sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0) val min5minCarbImpact = sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)
// tune DIA // tune DIA
var newDia = dia var newDia = dia

View file

@ -96,12 +96,12 @@ class AutotuneFragment : DaggerFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
sp.putBoolean(info.nightscout.core.utils.R.string.key_autotune_tune_insulin_curve, false) // put to false tune insulin curve sp.putBoolean(app.aaps.core.utils.R.string.key_autotune_tune_insulin_curve, false) // put to false tune insulin curve
sp.putBoolean(info.nightscout.core.utils.R.string.key_autotune_additional_log, false) // put to false additional log sp.putBoolean(app.aaps.core.utils.R.string.key_autotune_additional_log, false) // put to false additional log
autotunePlugin.loadLastRun() autotunePlugin.loadLastRun()
if (autotunePlugin.lastNbDays.isEmpty()) if (autotunePlugin.lastNbDays.isEmpty())
autotunePlugin.lastNbDays = sp.getInt(info.nightscout.core.utils.R.string.key_autotune_default_tune_days, 5).toString() autotunePlugin.lastNbDays = sp.getInt(app.aaps.core.utils.R.string.key_autotune_default_tune_days, 5).toString()
val defaultValue = sp.getInt(info.nightscout.core.utils.R.string.key_autotune_default_tune_days, 5).toDouble() val defaultValue = sp.getInt(app.aaps.core.utils.R.string.key_autotune_default_tune_days, 5).toDouble()
profileStore = activePlugin.activeProfileSource.profile ?: instantiator.provideProfileStore(JSONObject()) profileStore = activePlugin.activeProfileSource.profile ?: instantiator.provideProfileStore(JSONObject())
profileName = if (binding.profileList.text.toString() == rh.gs(app.aaps.core.ui.R.string.active)) "" else binding.profileList.text.toString() profileName = if (binding.profileList.text.toString() == rh.gs(app.aaps.core.ui.R.string.active)) "" else binding.profileList.text.toString()
profileFunction.getProfile()?.let { currentProfile -> profileFunction.getProfile()?.let { currentProfile ->
@ -150,7 +150,7 @@ class AutotuneFragment : DaggerFragment() {
binding.autotuneCopyLocal.setOnClickListener { binding.autotuneCopyLocal.setOnClickListener {
val localName = rh.gs(app.aaps.core.ui.R.string.autotune_tunedprofile_name) + " " + dateUtil.dateAndTimeString(autotunePlugin.lastRun) val localName = rh.gs(app.aaps.core.ui.R.string.autotune_tunedprofile_name) + " " + dateUtil.dateAndTimeString(autotunePlugin.lastRun)
val circadian = sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_circadian_ic_isf, false) val circadian = sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_circadian_ic_isf, false)
autotunePlugin.tunedProfile?.let { tunedProfile -> autotunePlugin.tunedProfile?.let { tunedProfile ->
OKDialog.showConfirmation(requireContext(), OKDialog.showConfirmation(requireContext(),
rh.gs(app.aaps.core.ui.R.string.autotune_copy_localprofile_button), rh.gs(app.aaps.core.ui.R.string.autotune_copy_localprofile_button),
@ -233,7 +233,7 @@ class AutotuneFragment : DaggerFragment() {
binding.autotuneCompare.setOnClickListener { binding.autotuneCompare.setOnClickListener {
val pumpProfile = autotunePlugin.pumpProfile val pumpProfile = autotunePlugin.pumpProfile
val circadian = sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_circadian_ic_isf, false) val circadian = sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_circadian_ic_isf, false)
val tunedProfile = if (circadian) autotunePlugin.tunedProfile?.circadianProfile else autotunePlugin.tunedProfile?.profile val tunedProfile = if (circadian) autotunePlugin.tunedProfile?.circadianProfile else autotunePlugin.tunedProfile?.profile
uiInteraction.runProfileViewerDialog( uiInteraction.runProfileViewerDialog(
fragmentManager = childFragmentManager, fragmentManager = childFragmentManager,
@ -248,7 +248,7 @@ class AutotuneFragment : DaggerFragment() {
binding.autotuneProfileswitch.setOnClickListener { binding.autotuneProfileswitch.setOnClickListener {
val tunedProfile = autotunePlugin.tunedProfile val tunedProfile = autotunePlugin.tunedProfile
autotunePlugin.updateProfile(tunedProfile) autotunePlugin.updateProfile(tunedProfile)
val circadian = sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_circadian_ic_isf, false) val circadian = sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_circadian_ic_isf, false)
tunedProfile?.let { tunedP -> tunedProfile?.let { tunedP ->
tunedP.profileStore(circadian)?.let { tunedP.profileStore(circadian)?.let {
OKDialog.showConfirmation(requireContext(), OKDialog.showConfirmation(requireContext(),
@ -400,7 +400,7 @@ class AutotuneFragment : DaggerFragment() {
private fun resetParam(resetDay: Boolean) { private fun resetParam(resetDay: Boolean) {
binding.tuneWarning.text = addWarnings() binding.tuneWarning.text = addWarnings()
if (resetDay) { if (resetDay) {
autotunePlugin.lastNbDays = sp.getInt(info.nightscout.core.utils.R.string.key_autotune_default_tune_days, 5).toString() autotunePlugin.lastNbDays = sp.getInt(app.aaps.core.utils.R.string.key_autotune_default_tune_days, 5).toString()
days.setAll(true) days.setAll(true)
} }
autotunePlugin.result = "" autotunePlugin.result = ""
@ -452,7 +452,7 @@ class AutotuneFragment : DaggerFragment() {
}) })
autotunePlugin.tunedProfile?.let { tuned -> autotunePlugin.tunedProfile?.let { tuned ->
layout.addView(toTableRowHeader(context)) layout.addView(toTableRowHeader(context))
val tuneInsulin = sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_tune_insulin_curve, false) val tuneInsulin = sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_tune_insulin_curve, false)
if (tuneInsulin) { if (tuneInsulin) {
layout.addView( layout.addView(
toTableRowValue( toTableRowValue(

View file

@ -255,7 +255,7 @@ open class AutotuneIob @Inject constructor(
private fun getCalculationToTimeTreatments(time: Long, localInsulin: LocalInsulin): IobTotal { private fun getCalculationToTimeTreatments(time: Long, localInsulin: LocalInsulin): IobTotal {
val total = IobTotal(time) val total = IobTotal(time)
val detailedLog = sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_additional_log, false) val detailedLog = sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_additional_log, false)
for (pos in boluses.indices) { for (pos in boluses.indices) {
val t = boluses[pos] val t = boluses[pos]
if (!t.isValid) continue if (!t.isValid) continue

View file

@ -120,7 +120,7 @@ class AutotunePlugin @Inject constructor(
calculationRunning = false calculationRunning = false
return return
} }
val detailedLog = sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_additional_log, false) val detailedLog = sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_additional_log, false)
calculationRunning = true calculationRunning = true
lastNbDays = "" + daysBack lastNbDays = "" + daysBack
lastRun = dateUtil.now() lastRun = dateUtil.now()
@ -223,7 +223,7 @@ class AutotunePlugin @Inject constructor(
updateButtonVisibility = View.VISIBLE updateButtonVisibility = View.VISIBLE
if (autoSwitch) { if (autoSwitch) {
val circadian = sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_circadian_ic_isf, false) val circadian = sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_circadian_ic_isf, false)
tunedProfile?.let { tunedP -> tunedProfile?.let { tunedP ->
tunedP.profileName = pumpProfile.profileName tunedP.profileName = pumpProfile.profileName
updateProfile(tunedP) updateProfile(tunedP)
@ -277,7 +277,7 @@ class AutotunePlugin @Inject constructor(
var strResult = line var strResult = line
strResult += rh.gs(app.aaps.core.ui.R.string.autotune_log_title) strResult += rh.gs(app.aaps.core.ui.R.string.autotune_log_title)
strResult += line strResult += line
val tuneInsulin = sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_tune_insulin_curve, false) val tuneInsulin = sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_tune_insulin_curve, false)
if (tuneInsulin) { if (tuneInsulin) {
strResult += rh.gs(app.aaps.core.ui.R.string.autotune_log_peak, rh.gs(R.string.insulin_peak), pumpProfile.localInsulin.peak, tunedProfile.localInsulin.peak) strResult += rh.gs(app.aaps.core.ui.R.string.autotune_log_peak, rh.gs(R.string.insulin_peak), pumpProfile.localInsulin.peak, tunedProfile.localInsulin.peak)
strResult += rh.gs(app.aaps.core.ui.R.string.autotune_log_dia, rh.gs(app.aaps.core.ui.R.string.ic_short), pumpProfile.localInsulin.dia, tunedProfile.localInsulin.dia) strResult += rh.gs(app.aaps.core.ui.R.string.autotune_log_dia, rh.gs(app.aaps.core.ui.R.string.ic_short), pumpProfile.localInsulin.dia, tunedProfile.localInsulin.dia)
@ -308,16 +308,16 @@ class AutotunePlugin @Inject constructor(
val utcOffset = T.msecs(TimeZone.getDefault().getOffset(dateUtil.now()).toLong()).hours() val utcOffset = T.msecs(TimeZone.getDefault().getOffset(dateUtil.now()).toLong()).hours()
val startDateString = dateUtil.toISOString(firstLoopStart).substring(0, 10) val startDateString = dateUtil.toISOString(firstLoopStart).substring(0, 10)
val endDateString = dateUtil.toISOString(lastLoopEnd - 24 * 60 * 60 * 1000L).substring(0, 10) val endDateString = dateUtil.toISOString(lastLoopEnd - 24 * 60 * 60 * 1000L).substring(0, 10)
val nsUrl = sp.getString(info.nightscout.core.utils.R.string.key_nsclientinternal_url, "") val nsUrl = sp.getString(app.aaps.core.utils.R.string.key_nsclientinternal_url, "")
val optCategorizeUam = if (sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_categorize_uam_as_basal, false)) "-c=true" else "" val optCategorizeUam = if (sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_categorize_uam_as_basal, false)) "-c=true" else ""
val optInsulinCurve = if (sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_tune_insulin_curve, false)) "-i=true" else "" val optInsulinCurve = if (sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_tune_insulin_curve, false)) "-i=true" else ""
try { try {
jsonSettings.put("datestring", dateUtil.toISOString(runDate)) jsonSettings.put("datestring", dateUtil.toISOString(runDate))
jsonSettings.put("dateutc", dateUtil.toISOAsUTC(runDate)) jsonSettings.put("dateutc", dateUtil.toISOAsUTC(runDate))
jsonSettings.put("utcOffset", utcOffset) jsonSettings.put("utcOffset", utcOffset)
jsonSettings.put("units", profileFunction.getUnits().asText) jsonSettings.put("units", profileFunction.getUnits().asText)
jsonSettings.put("timezone", TimeZone.getDefault().id) jsonSettings.put("timezone", TimeZone.getDefault().id)
jsonSettings.put("url_nightscout", sp.getString(info.nightscout.core.utils.R.string.key_nsclientinternal_url, "")) jsonSettings.put("url_nightscout", sp.getString(app.aaps.core.utils.R.string.key_nsclientinternal_url, ""))
jsonSettings.put("nbdays", nbDays) jsonSettings.put("nbdays", nbDays)
jsonSettings.put("startdate", startDateString) jsonSettings.put("startdate", startDateString)
jsonSettings.put("enddate", endDateString) jsonSettings.put("enddate", endDateString)
@ -327,7 +327,7 @@ class AutotunePlugin @Inject constructor(
jsonSettings.put("oref0_command", "oref0-autotune -d=~/aaps -n=$nsUrl -s=$startDateString -e=$endDateString $optCategorizeUam $optInsulinCurve") jsonSettings.put("oref0_command", "oref0-autotune -d=~/aaps -n=$nsUrl -s=$startDateString -e=$endDateString $optCategorizeUam $optInsulinCurve")
// aaps_command is for running modified oref0-autotune with exported data from aaps (ns-entries and ns-treatment json files copied in ~/aaps/autotune folder and pumpprofile.json copied in ~/aaps/settings/ // aaps_command is for running modified oref0-autotune with exported data from aaps (ns-entries and ns-treatment json files copied in ~/aaps/autotune folder and pumpprofile.json copied in ~/aaps/settings/
jsonSettings.put("aaps_command", "aaps-autotune -d=~/aaps -s=$startDateString -e=$endDateString $optCategorizeUam $optInsulinCurve") jsonSettings.put("aaps_command", "aaps-autotune -d=~/aaps -s=$startDateString -e=$endDateString $optCategorizeUam $optInsulinCurve")
jsonSettings.put("categorize_uam_as_basal", sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_categorize_uam_as_basal, false)) jsonSettings.put("categorize_uam_as_basal", sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_categorize_uam_as_basal, false))
jsonSettings.put("tune_insulin_curve", false) jsonSettings.put("tune_insulin_curve", false)
val peakTime: Int = insulinInterface.peak val peakTime: Int = insulinInterface.peak
@ -354,7 +354,7 @@ class AutotunePlugin @Inject constructor(
fun updateProfile(newProfile: ATProfile?) { fun updateProfile(newProfile: ATProfile?) {
if (newProfile == null) return if (newProfile == null) return
val profilePlugin = activePlugin.activeProfileSource val profilePlugin = activePlugin.activeProfileSource
val circadian = sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_circadian_ic_isf, false) val circadian = sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_circadian_ic_isf, false)
val profileStore = activePlugin.activeProfileSource.profile ?: instantiator.provideProfileStore(JSONObject()) val profileStore = activePlugin.activeProfileSource.profile ?: instantiator.provideProfileStore(JSONObject())
val profileList: ArrayList<CharSequence> = profileStore.getProfileList() val profileList: ArrayList<CharSequence> = profileStore.getProfileList()
var indexLocalProfile = -1 var indexLocalProfile = -1
@ -396,14 +396,14 @@ class AutotunePlugin @Inject constructor(
} }
json.put("result", result) json.put("result", result)
json.put("updateButtonVisibility", updateButtonVisibility) json.put("updateButtonVisibility", updateButtonVisibility)
sp.putString(info.nightscout.core.utils.R.string.key_autotune_last_run, json.toString()) sp.putString(app.aaps.core.utils.R.string.key_autotune_last_run, json.toString())
} }
fun loadLastRun() { fun loadLastRun() {
result = "" result = ""
lastRunSuccess = false lastRunSuccess = false
try { try {
val json = JSONObject(sp.getString(info.nightscout.core.utils.R.string.key_autotune_last_run, "")) val json = JSONObject(sp.getString(app.aaps.core.utils.R.string.key_autotune_last_run, ""))
lastNbDays = JsonHelper.safeGetString(json, "lastNbDays", "") lastNbDays = JsonHelper.safeGetString(json, "lastNbDays", "")
lastRun = JsonHelper.safeGetLong(json, "lastRun") lastRun = JsonHelper.safeGetLong(json, "lastRun")
val pumpPeak = JsonHelper.safeGetInt(json, "pumpPeak") val pumpPeak = JsonHelper.safeGetInt(json, "pumpPeak")

View file

@ -32,7 +32,7 @@ class AutotunePrep @Inject constructor(
fun categorize(tunedProfile: ATProfile): PreppedGlucose? { fun categorize(tunedProfile: ATProfile): PreppedGlucose? {
val preppedGlucose = categorizeBGDatums(tunedProfile, tunedProfile.localInsulin) val preppedGlucose = categorizeBGDatums(tunedProfile, tunedProfile.localInsulin)
val tuneInsulin = sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_tune_insulin_curve, false) val tuneInsulin = sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_tune_insulin_curve, false)
if (tuneInsulin) { if (tuneInsulin) {
var minDeviations = 1000000.0 var minDeviations = 1000000.0
val diaDeviations: MutableList<DiaDeviation> = ArrayList() val diaDeviations: MutableList<DiaDeviation> = ArrayList()
@ -312,7 +312,7 @@ class AutotunePrep @Inject constructor(
// Then, calculate carb absorption for that 5m interval using the deviation. // Then, calculate carb absorption for that 5m interval using the deviation.
if (mealCOB > 0) { if (mealCOB > 0) {
val ci = max(deviation, sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)) val ci = max(deviation, sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0))
val absorbed = ci * tunedProfile.ic / sens val absorbed = ci * tunedProfile.ic / sens
// Store the COB, and use it as the starting point for the next data point. // Store the COB, and use it as the starting point for the next data point.
mealCOB = max(0.0, mealCOB - absorbed) mealCOB = max(0.0, mealCOB - absorbed)
@ -463,7 +463,7 @@ class AutotunePrep @Inject constructor(
var isfLength = isfGlucoseData.size var isfLength = isfGlucoseData.size
val uamLength = uamGlucoseData.size val uamLength = uamGlucoseData.size
var basalLength = basalGlucoseData.size var basalLength = basalGlucoseData.size
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_categorize_uam_as_basal, false)) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_categorize_uam_as_basal, false)) {
//aapsLogger.debug(LTag.AUTOTUNE, "Categorizing all UAM data as basal.") //aapsLogger.debug(LTag.AUTOTUNE, "Categorizing all UAM data as basal.")
if (verbose) if (verbose)
log("Categorizing all UAM data as basal.") log("Categorizing all UAM data as basal.")

View file

@ -114,7 +114,7 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector:
json.put("useCustomPeakTime", true) json.put("useCustomPeakTime", true)
json.put("insulinPeakTime", 45) json.put("insulinPeakTime", 45)
} else if (insulinInterface.id === Insulin.InsulinType.OREF_FREE_PEAK) { } else if (insulinInterface.id === Insulin.InsulinType.OREF_FREE_PEAK) {
val peakTime: Int = sp.getInt(rh.gs(info.nightscout.core.utils.R.string.key_insulin_oref_peak), 75) val peakTime: Int = sp.getInt(rh.gs(app.aaps.core.utils.R.string.key_insulin_oref_peak), 75)
json.put("curve", if (peakTime > 50) "rapid-acting" else "ultra-rapid") json.put("curve", if (peakTime > 50) "rapid-acting" else "ultra-rapid")
json.put("useCustomPeakTime", true) json.put("useCustomPeakTime", true)
json.put("insulinPeakTime", peakTime) json.put("insulinPeakTime", peakTime)
@ -142,8 +142,8 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector:
) )
) )
json.put("carb_ratio", avgIC) json.put("carb_ratio", avgIC)
json.put("autosens_max", SafeParse.stringToDouble(sp.getString(info.nightscout.core.utils.R.string.key_openapsama_autosens_max, "1.2"))) json.put("autosens_max", SafeParse.stringToDouble(sp.getString(app.aaps.core.utils.R.string.key_openapsama_autosens_max, "1.2")))
json.put("autosens_min", SafeParse.stringToDouble(sp.getString(info.nightscout.core.utils.R.string.key_openapsama_autosens_min, "0.7"))) json.put("autosens_min", SafeParse.stringToDouble(sp.getString(app.aaps.core.utils.R.string.key_openapsama_autosens_min, "0.7")))
json.put("units", GlucoseUnit.MGDL.asText) json.put("units", GlucoseUnit.MGDL.asText)
json.put("timezone", TimeZone.getDefault().id) json.put("timezone", TimeZone.getDefault().id)
jsonString = json.toString(2).replace("\\/", "/") jsonString = json.toString(2).replace("\\/", "/")

View file

@ -116,7 +116,7 @@ class LoopFragment : DaggerFragment(), MenuProvider {
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
updateGUI() updateGUI()
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectiveuseloop, true) sp.putBoolean(app.aaps.core.utils.R.string.key_objectiveuseloop, true)
} }
@Synchronized @Synchronized

View file

@ -183,7 +183,7 @@ class LoopPlugin @Inject constructor(
get() { get() {
val closedLoopEnabled = constraintChecker.isClosedLoopAllowed() val closedLoopEnabled = constraintChecker.isClosedLoopAllowed()
val maxIobAllowed = constraintChecker.getMaxIOBAllowed().value() val maxIobAllowed = constraintChecker.getMaxIOBAllowed().value()
val apsMode = ApsMode.fromString(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)) val apsMode = ApsMode.fromString(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name))
val pump = activePlugin.activePump val pump = activePlugin.activePump
var isLGS = false var isLGS = false
if (!isSuspended && !pump.isSuspended()) if (closedLoopEnabled.value()) if (maxIobAllowed == HardLimits.MAX_IOB_LGS || apsMode == ApsMode.LGS) isLGS = true if (!isSuspended && !pump.isSuspended()) if (closedLoopEnabled.value()) if (maxIobAllowed == HardLimits.MAX_IOB_LGS || apsMode == ApsMode.LGS) isLGS = true
@ -322,18 +322,18 @@ class LoopPlugin @Inject constructor(
) && carbsSuggestionsSuspendedUntil < System.currentTimeMillis() && !treatmentTimeThreshold(-15) ) && carbsSuggestionsSuspendedUntil < System.currentTimeMillis() && !treatmentTimeThreshold(-15)
) { ) {
if (sp.getBoolean( if (sp.getBoolean(
info.nightscout.core.utils.R.string.key_enable_carbs_required_alert_local, app.aaps.core.utils.R.string.key_enable_carbs_required_alert_local,
true true
) && !sp.getBoolean(app.aaps.core.ui.R.string.key_raise_notifications_as_android_notifications, true) ) && !sp.getBoolean(app.aaps.core.ui.R.string.key_raise_notifications_as_android_notifications, true)
) { ) {
val carbReqLocal = Notification(Notification.CARBS_REQUIRED, resultAfterConstraints.carbsRequiredText, Notification.NORMAL) val carbReqLocal = Notification(Notification.CARBS_REQUIRED, resultAfterConstraints.carbsRequiredText, Notification.NORMAL)
rxBus.send(EventNewNotification(carbReqLocal)) rxBus.send(EventNewNotification(carbReqLocal))
} }
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_create_announcements_from_carbs_req, false)) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_create_announcements_from_carbs_req, false)) {
disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(resultAfterConstraints.carbsRequiredText)).subscribe() disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(resultAfterConstraints.carbsRequiredText)).subscribe()
} }
if (sp.getBoolean( if (sp.getBoolean(
info.nightscout.core.utils.R.string.key_enable_carbs_required_alert_local, app.aaps.core.utils.R.string.key_enable_carbs_required_alert_local,
true true
) && sp.getBoolean(app.aaps.core.ui.R.string.key_raise_notifications_as_android_notifications, true) ) && sp.getBoolean(app.aaps.core.ui.R.string.key_raise_notifications_as_android_notifications, true)
) { ) {
@ -442,7 +442,7 @@ class LoopPlugin @Inject constructor(
.setPriority(Notification.IMPORTANCE_HIGH) .setPriority(Notification.IMPORTANCE_HIGH)
.setCategory(Notification.CATEGORY_ALARM) .setCategory(Notification.CATEGORY_ALARM)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_control, false)) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_wear_control, false)) {
builder.setLocalOnly(true) builder.setLocalOnly(true)
} }
presentSuggestion(builder) presentSuggestion(builder)
@ -519,7 +519,7 @@ class LoopPlugin @Inject constructor(
lastRun.lastTBREnact = dateUtil.now() lastRun.lastTBREnact = dateUtil.now()
lastRun.lastOpenModeAccept = dateUtil.now() lastRun.lastOpenModeAccept = dateUtil.now()
buildAndStoreDeviceStatus() buildAndStoreDeviceStatus()
sp.incInt(info.nightscout.core.utils.R.string.key_ObjectivesmanualEnacts) sp.incInt(app.aaps.core.utils.R.string.key_ObjectivesmanualEnacts)
} }
rxBus.send(EventAcceptOpenLoopChange()) rxBus.send(EventAcceptOpenLoopChange())
} }

View file

@ -191,7 +191,7 @@ class DetermineBasalAdapterAMAJS internal constructor(scriptReader: ScriptReader
if (mealData.usedMinCarbsImpact > 0) { if (mealData.usedMinCarbsImpact > 0) {
this.profile.put("min_5m_carbimpact", mealData.usedMinCarbsImpact) this.profile.put("min_5m_carbimpact", mealData.usedMinCarbsImpact)
} else { } else {
this.profile.put("min_5m_carbimpact", sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact)) this.profile.put("min_5m_carbimpact", sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact))
} }
if (profileFunction.getUnits() == GlucoseUnit.MMOL) { if (profileFunction.getUnits() == GlucoseUnit.MMOL) {
this.profile.put("out_units", "mmol/L") this.profile.put("out_units", "mmol/L")

View file

@ -270,7 +270,7 @@ class OpenAPSAMAPlugin @Inject constructor(
} }
override fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> { override fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
val enabled = sp.getBoolean(info.nightscout.core.utils.R.string.key_use_autosens, false) val enabled = sp.getBoolean(app.aaps.core.utils.R.string.key_use_autosens, false)
if (!enabled) value.set(false, rh.gs(R.string.autosens_disabled_in_preferences), this) if (!enabled) value.set(false, rh.gs(R.string.autosens_disabled_in_preferences), this)
return value return value
} }

View file

@ -230,7 +230,7 @@ class DetermineBasalAdapterSMBJS internal constructor(private val scriptReader:
this.profile.put("carbsReqThreshold", sp.getInt(R.string.key_carbsReqThreshold, SMBDefaults.carbsReqThreshold)) this.profile.put("carbsReqThreshold", sp.getInt(R.string.key_carbsReqThreshold, SMBDefaults.carbsReqThreshold))
this.profile.put("current_basal", basalRate) this.profile.put("current_basal", basalRate)
this.profile.put("temptargetSet", tempTargetSet) this.profile.put("temptargetSet", tempTargetSet)
this.profile.put("autosens_max", SafeParse.stringToDouble(sp.getString(info.nightscout.core.utils.R.string.key_openapsama_autosens_max, "1.2"))) this.profile.put("autosens_max", SafeParse.stringToDouble(sp.getString(app.aaps.core.utils.R.string.key_openapsama_autosens_max, "1.2")))
if (profileFunction.getUnits() == GlucoseUnit.MMOL) { if (profileFunction.getUnits() == GlucoseUnit.MMOL) {
this.profile.put("out_units", "mmol/L") this.profile.put("out_units", "mmol/L")
} }

View file

@ -348,7 +348,7 @@ open class OpenAPSSMBPlugin @Inject constructor(
} }
override fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> { override fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
val enabled = sp.getBoolean(info.nightscout.core.utils.R.string.key_use_autosens, false) val enabled = sp.getBoolean(app.aaps.core.utils.R.string.key_use_autosens, false)
if (!enabled) value.set(false, rh.gs(R.string.autosens_disabled_in_preferences), this) if (!enabled) value.set(false, rh.gs(R.string.autosens_disabled_in_preferences), this)
return value return value
} }

View file

@ -209,10 +209,10 @@ class DetermineBasalAdapterSMBDynamicISFJS internal constructor(private val scri
//mProfile.put("high_temptarget_raises_sensitivity", SP.getBoolean(R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity)); //mProfile.put("high_temptarget_raises_sensitivity", SP.getBoolean(R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity));
this.profile.put( this.profile.put(
"high_temptarget_raises_sensitivity", "high_temptarget_raises_sensitivity",
sp.getBoolean(info.nightscout.core.utils.R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity) sp.getBoolean(app.aaps.core.utils.R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity)
) )
//mProfile.put("low_temptarget_lowers_sensitivity", SP.getBoolean(R.string.key_low_temptarget_lowers_sensitivity, SMBDefaults.low_temptarget_lowers_sensitivity)); //mProfile.put("low_temptarget_lowers_sensitivity", SP.getBoolean(R.string.key_low_temptarget_lowers_sensitivity, SMBDefaults.low_temptarget_lowers_sensitivity));
this.profile.put("low_temptarget_lowers_sensitivity", sp.getBoolean(info.nightscout.core.utils.R.string.key_low_temptarget_lowers_sensitivity, SMBDefaults.low_temptarget_lowers_sensitivity)) this.profile.put("low_temptarget_lowers_sensitivity", sp.getBoolean(app.aaps.core.utils.R.string.key_low_temptarget_lowers_sensitivity, SMBDefaults.low_temptarget_lowers_sensitivity))
this.profile.put("sensitivity_raises_target", sp.getBoolean(R.string.key_sensitivity_raises_target, SMBDefaults.sensitivity_raises_target)) this.profile.put("sensitivity_raises_target", sp.getBoolean(R.string.key_sensitivity_raises_target, SMBDefaults.sensitivity_raises_target))
this.profile.put("resistance_lowers_target", sp.getBoolean(R.string.key_resistance_lowers_target, SMBDefaults.resistance_lowers_target)) this.profile.put("resistance_lowers_target", sp.getBoolean(R.string.key_resistance_lowers_target, SMBDefaults.resistance_lowers_target))
this.profile.put("adv_target_adjustments", SMBDefaults.adv_target_adjustments) this.profile.put("adv_target_adjustments", SMBDefaults.adv_target_adjustments)
@ -244,8 +244,8 @@ class DetermineBasalAdapterSMBDynamicISFJS internal constructor(private val scri
this.profile.put("carbsReqThreshold", sp.getInt(R.string.key_carbsReqThreshold, SMBDefaults.carbsReqThreshold)) this.profile.put("carbsReqThreshold", sp.getInt(R.string.key_carbsReqThreshold, SMBDefaults.carbsReqThreshold))
this.profile.put("current_basal", basalRate) this.profile.put("current_basal", basalRate)
this.profile.put("temptargetSet", tempTargetSet) this.profile.put("temptargetSet", tempTargetSet)
this.profile.put("autosens_max", SafeParse.stringToDouble(sp.getString(info.nightscout.core.utils.R.string.key_openapsama_autosens_max, "1.2"))) this.profile.put("autosens_max", SafeParse.stringToDouble(sp.getString(app.aaps.core.utils.R.string.key_openapsama_autosens_max, "1.2")))
this.profile.put("autosens_min", SafeParse.stringToDouble(sp.getString(info.nightscout.core.utils.R.string.key_openapsama_autosens_min, "0.7"))) this.profile.put("autosens_min", SafeParse.stringToDouble(sp.getString(app.aaps.core.utils.R.string.key_openapsama_autosens_min, "0.7")))
//set the min SMB amount to be the amount set by the pump. //set the min SMB amount to be the amount set by the pump.
if (profileFunction.getUnits() == GlucoseUnit.MMOL) { if (profileFunction.getUnits() == GlucoseUnit.MMOL) {
this.profile.put("out_units", "mmol/L") this.profile.put("out_units", "mmol/L")

View file

@ -44,9 +44,9 @@ class AutotuneCoreTest : TestBaseWithProfile() {
val inputProfile = atProfileFromOapsJson(JSONObject(inputProfileJson), dateUtil)!! val inputProfile = atProfileFromOapsJson(JSONObject(inputProfileJson), dateUtil)!!
val prep = PreppedGlucose(JSONObject(prepJson), dateUtil) val prep = PreppedGlucose(JSONObject(prepJson), dateUtil)
`when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_max, 1.2)).thenReturn(autotuneMax) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_autosens_max, 1.2)).thenReturn(autotuneMax)
`when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_min, 0.7)).thenReturn(autotuneMin) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_autosens_min, 0.7)).thenReturn(autotuneMin)
`when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact)
val oapsOutputProfileJson = File("src/test/res/autotune/test1/aapsorefprofile.json").readText() val oapsOutputProfileJson = File("src/test/res/autotune/test1/aapsorefprofile.json").readText()
val oapsOutputProfile = atProfileFromOapsJson(JSONObject(oapsOutputProfileJson), dateUtil)!! val oapsOutputProfile = atProfileFromOapsJson(JSONObject(oapsOutputProfileJson), dateUtil)!!
val outProfile = autotuneCore.tuneAllTheThings(prep, inputProfile, inputProfile) val outProfile = autotuneCore.tuneAllTheThings(prep, inputProfile, inputProfile)
@ -66,9 +66,9 @@ class AutotuneCoreTest : TestBaseWithProfile() {
val pumpProfileJson = File("src/test/res/autotune/test4/profile.pump.json").readText() val pumpProfileJson = File("src/test/res/autotune/test4/profile.pump.json").readText()
val pumpProfile = atProfileFromOapsJson(JSONObject(pumpProfileJson), dateUtil)!! val pumpProfile = atProfileFromOapsJson(JSONObject(pumpProfileJson), dateUtil)!!
val prep = PreppedGlucose(JSONObject(prepJson), dateUtil) val prep = PreppedGlucose(JSONObject(prepJson), dateUtil)
`when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_max, 1.2)).thenReturn(autotuneMax) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_autosens_max, 1.2)).thenReturn(autotuneMax)
`when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_min, 0.7)).thenReturn(autotuneMin) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_autosens_min, 0.7)).thenReturn(autotuneMin)
`when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact)
val oapsOutputProfileJson = File("src/test/res/autotune/test4/newprofile.2022-05-30.json").readText() val oapsOutputProfileJson = File("src/test/res/autotune/test4/newprofile.2022-05-30.json").readText()
val oapsOutputProfile = atProfileFromOapsJson(JSONObject(oapsOutputProfileJson), dateUtil)!! val oapsOutputProfile = atProfileFromOapsJson(JSONObject(oapsOutputProfileJson), dateUtil)!!
val outProfile = autotuneCore.tuneAllTheThings(prep, inputProfile, pumpProfile) val outProfile = autotuneCore.tuneAllTheThings(prep, inputProfile, pumpProfile)

View file

@ -63,8 +63,8 @@ class AutotunePrepTest : TestBaseWithProfile() {
val oapsTreatmentsJson = File("src/test/res/autotune/test1/aaps-treatments.2022-05-21.json").readText() val oapsTreatmentsJson = File("src/test/res/autotune/test1/aaps-treatments.2022-05-21.json").readText()
autotuneIob.meals = buildMeals(JSONArray(oapsTreatmentsJson)) //Only meals is used in unit test, Insulin only used for iob calculation autotuneIob.meals = buildMeals(JSONArray(oapsTreatmentsJson)) //Only meals is used in unit test, Insulin only used for iob calculation
autotuneIob.boluses = buildBoluses(oapsPreppedGlucose) //Values from oapsPrepData because linked to iob calculation method for TBR autotuneIob.boluses = buildBoluses(oapsPreppedGlucose) //Values from oapsPrepData because linked to iob calculation method for TBR
`when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact)
`when`(sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_categorize_uam_as_basal, false)).thenReturn(false) `when`(sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_categorize_uam_as_basal, false)).thenReturn(false)
val aapsPreppedGlucose = autotunePrep.categorizeBGDatums(inputProfile, inputProfile.localInsulin, false)!! val aapsPreppedGlucose = autotunePrep.categorizeBGDatums(inputProfile, inputProfile.localInsulin, false)!!
// compare all categorization calculated by aaps plugin (aapsPreppedGlucose) with categorization calculated by OpenAPS (oapsPreppedGlucose) // compare all categorization calculated by aaps plugin (aapsPreppedGlucose) with categorization calculated by OpenAPS (oapsPreppedGlucose)
for (i in aapsPreppedGlucose.crData.indices) for (i in aapsPreppedGlucose.crData.indices)
@ -96,8 +96,8 @@ class AutotunePrepTest : TestBaseWithProfile() {
val oapsTreatmentsJson = File("src/test/res/autotune/test2/aaps-treatments.2022-05-21.json").readText() val oapsTreatmentsJson = File("src/test/res/autotune/test2/aaps-treatments.2022-05-21.json").readText()
autotuneIob.meals = buildMeals(JSONArray(oapsTreatmentsJson)) //Only meals is used in unit test, Insulin only used for iob calculation autotuneIob.meals = buildMeals(JSONArray(oapsTreatmentsJson)) //Only meals is used in unit test, Insulin only used for iob calculation
autotuneIob.boluses = buildBoluses(oapsPreppedGlucose) //Values from oapsPrepData because linked to iob calculation method for TBR autotuneIob.boluses = buildBoluses(oapsPreppedGlucose) //Values from oapsPrepData because linked to iob calculation method for TBR
`when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact)
`when`(sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_categorize_uam_as_basal, false)).thenReturn(false) // CategorizeUAM as Basal = False `when`(sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_categorize_uam_as_basal, false)).thenReturn(false) // CategorizeUAM as Basal = False
val aapsPreppedGlucose = autotunePrep.categorizeBGDatums(inputProfile, inputProfile.localInsulin, false)!! val aapsPreppedGlucose = autotunePrep.categorizeBGDatums(inputProfile, inputProfile.localInsulin, false)!!
// compare all categorization calculated by aaps plugin (aapsPreppedGlucose) with categorization calculated by OpenAPS (oapsPreppedGlucose) // compare all categorization calculated by aaps plugin (aapsPreppedGlucose) with categorization calculated by OpenAPS (oapsPreppedGlucose)
for (i in aapsPreppedGlucose.crData.indices) for (i in aapsPreppedGlucose.crData.indices)
@ -129,8 +129,8 @@ class AutotunePrepTest : TestBaseWithProfile() {
val oapsTreatmentsJson = File("src/test/res/autotune/test3/aaps-treatments.2022-05-21.json").readText() val oapsTreatmentsJson = File("src/test/res/autotune/test3/aaps-treatments.2022-05-21.json").readText()
autotuneIob.meals = buildMeals(JSONArray(oapsTreatmentsJson)) //Only meals is used in unit test, Insulin only used for iob calculation autotuneIob.meals = buildMeals(JSONArray(oapsTreatmentsJson)) //Only meals is used in unit test, Insulin only used for iob calculation
autotuneIob.boluses = buildBoluses(oapsPreppedGlucose) //Values from oapsPrepData because linked to iob calculation method for TBR autotuneIob.boluses = buildBoluses(oapsPreppedGlucose) //Values from oapsPrepData because linked to iob calculation method for TBR
`when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact)
`when`(sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_categorize_uam_as_basal, false)).thenReturn(true) // CategorizeUAM as Basal = True `when`(sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_categorize_uam_as_basal, false)).thenReturn(true) // CategorizeUAM as Basal = True
val aapsPreppedGlucose = autotunePrep.categorizeBGDatums(inputProfile, inputProfile.localInsulin, false)!! val aapsPreppedGlucose = autotunePrep.categorizeBGDatums(inputProfile, inputProfile.localInsulin, false)!!
// compare all categorization calculated by aaps plugin (aapsPreppedGlucose) with categorization calculated by OpenAPS (oapsPreppedGlucose) // compare all categorization calculated by aaps plugin (aapsPreppedGlucose) with categorization calculated by OpenAPS (oapsPreppedGlucose)
for (i in aapsPreppedGlucose.crData.indices) for (i in aapsPreppedGlucose.crData.indices)

View file

@ -69,7 +69,7 @@ class LoopPluginTest : TestBase() {
fun testPluginInterface() { fun testPluginInterface() {
`when`(rh.gs(app.aaps.core.ui.R.string.loop)).thenReturn("Loop") `when`(rh.gs(app.aaps.core.ui.R.string.loop)).thenReturn("Loop")
`when`(rh.gs(app.aaps.plugins.aps.R.string.loop_shortname)).thenReturn("LOOP") `when`(rh.gs(app.aaps.plugins.aps.R.string.loop_shortname)).thenReturn("LOOP")
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name) `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
val pumpDescription = PumpDescription() val pumpDescription = PumpDescription()
`when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription) `when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription)
assertThat(loopPlugin.pluginDescription.fragmentClass).isEqualTo(LoopFragment::class.java.name) assertThat(loopPlugin.pluginDescription.fragmentClass).isEqualTo(LoopFragment::class.java.name)

View file

@ -39,7 +39,7 @@ class ActionRunAutotune(injector: HasAndroidInjector) : Action(injector) {
@DrawableRes override fun icon(): Int = app.aaps.core.ui.R.drawable.ic_actions_profileswitch @DrawableRes override fun icon(): Int = app.aaps.core.ui.R.drawable.ic_actions_profileswitch
override fun doAction(callback: Callback) { override fun doAction(callback: Callback) {
val autoSwitch = sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_auto, false) val autoSwitch = sp.getBoolean(app.aaps.core.utils.R.string.key_autotune_auto, false)
val profileName = if (inputProfileName.value == rh.gs(app.aaps.core.ui.R.string.active)) "" else inputProfileName.value val profileName = if (inputProfileName.value == rh.gs(app.aaps.core.ui.R.string.active)) "" else inputProfileName.value
var message = if (autoSwitch) app.aaps.core.ui.R.string.autotune_run_with_autoswitch else app.aaps.core.ui.R.string.autotune_run_without_autoswitch var message = if (autoSwitch) app.aaps.core.ui.R.string.autotune_run_with_autoswitch else app.aaps.core.ui.R.string.autotune_run_without_autoswitch
Thread { Thread {
@ -62,7 +62,7 @@ class ActionRunAutotune(injector: HasAndroidInjector) : Action(injector) {
override fun generateDialog(root: LinearLayout) { override fun generateDialog(root: LinearLayout) {
if (defaultValue == 0) if (defaultValue == 0)
defaultValue = sp.getInt(info.nightscout.core.utils.R.string.key_autotune_default_tune_days, 5) defaultValue = sp.getInt(app.aaps.core.utils.R.string.key_autotune_default_tune_days, 5)
daysBack.value = defaultValue daysBack.value = defaultValue
LayoutBuilder() LayoutBuilder()
.add(LabelWithElement(rh, rh.gs(app.aaps.core.ui.R.string.autotune_select_profile), "", inputProfileName)) .add(LabelWithElement(rh, rh.gs(app.aaps.core.ui.R.string.autotune_select_profile), "", inputProfileName))
@ -93,7 +93,7 @@ class ActionRunAutotune(injector: HasAndroidInjector) : Action(injector) {
inputProfileName.value = JsonHelper.safeGetString(o, "profileToTune", "") inputProfileName.value = JsonHelper.safeGetString(o, "profileToTune", "")
defaultValue = JsonHelper.safeGetInt(o, "tunedays") defaultValue = JsonHelper.safeGetInt(o, "tunedays")
if (defaultValue == 0) if (defaultValue == 0)
defaultValue = sp.getInt(info.nightscout.core.utils.R.string.key_autotune_default_tune_days, 5) defaultValue = sp.getInt(app.aaps.core.utils.R.string.key_autotune_default_tune_days, 5)
daysBack.value = defaultValue daysBack.value = defaultValue
return this return this
} }

View file

@ -17,8 +17,8 @@ import java.util.Optional
class TriggerAutosensValue(injector: HasAndroidInjector) : Trigger(injector) { class TriggerAutosensValue(injector: HasAndroidInjector) : Trigger(injector) {
private val minValue = (sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_min, 0.7) * 100).toInt() private val minValue = (sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_autosens_min, 0.7) * 100).toInt()
private val maxValue = (sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_max, 1.2) * 100).toInt() private val maxValue = (sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_autosens_max, 1.2) * 100).toInt()
private val step = 1.0 private val step = 1.0
private val decimalFormat = DecimalFormat("1") private val decimalFormat = DecimalFormat("1")
var autosens: InputDouble = InputDouble(100.0, minValue.toDouble(), maxValue.toDouble(), step, decimalFormat) var autosens: InputDouble = InputDouble(100.0, minValue.toDouble(), maxValue.toDouble(), step, decimalFormat)

View file

@ -18,7 +18,7 @@ import java.util.Optional
class TriggerCOB(injector: HasAndroidInjector) : Trigger(injector) { class TriggerCOB(injector: HasAndroidInjector) : Trigger(injector) {
private val minValue = 0 private val minValue = 0
private val maxValue = sp.getInt(info.nightscout.core.utils.R.string.key_treatmentssafety_maxcarbs, 48) private val maxValue = sp.getInt(app.aaps.core.utils.R.string.key_treatmentssafety_maxcarbs, 48)
var cob: InputDouble = InputDouble(0.0, minValue.toDouble(), maxValue.toDouble(), 1.0, DecimalFormat("1")) var cob: InputDouble = InputDouble(0.0, minValue.toDouble(), maxValue.toDouble(), 1.0, DecimalFormat("1"))
var comparator: Comparator = Comparator(rh) var comparator: Comparator = Comparator(rh)

View file

@ -14,8 +14,8 @@ import org.mockito.Mockito.`when`
class TriggerAutosensValueTest : TriggerTestBase() { class TriggerAutosensValueTest : TriggerTestBase() {
@Test fun shouldRunTest() { @Test fun shouldRunTest() {
`when`(sp.getDouble(Mockito.eq(info.nightscout.core.utils.R.string.key_openapsama_autosens_max), ArgumentMatchers.anyDouble())).thenReturn(1.2) `when`(sp.getDouble(Mockito.eq(app.aaps.core.utils.R.string.key_openapsama_autosens_max), ArgumentMatchers.anyDouble())).thenReturn(1.2)
`when`(sp.getDouble(Mockito.eq(info.nightscout.core.utils.R.string.key_openapsama_autosens_min), ArgumentMatchers.anyDouble())).thenReturn(0.7) `when`(sp.getDouble(Mockito.eq(app.aaps.core.utils.R.string.key_openapsama_autosens_min), ArgumentMatchers.anyDouble())).thenReturn(0.7)
`when`(autosensDataStore.getLastAutosensData(anyObject(), anyObject(), anyObject())).thenReturn(generateAutosensData()) `when`(autosensDataStore.getLastAutosensData(anyObject(), anyObject(), anyObject())).thenReturn(generateAutosensData())
var t = TriggerAutosensValue(injector) var t = TriggerAutosensValue(injector)
t.autosens.value = 110.0 t.autosens.value = 110.0

View file

@ -120,8 +120,8 @@ class RunningConfigurationImpl @Inject constructor(
} }
configuration.pump?.let { configuration.pump?.let {
if (sp.getString(info.nightscout.core.utils.R.string.key_virtualpump_type, "fake") != it) { if (sp.getString(app.aaps.core.utils.R.string.key_virtualpump_type, "fake") != it) {
sp.putString(info.nightscout.core.utils.R.string.key_virtualpump_type, it) sp.putString(app.aaps.core.utils.R.string.key_virtualpump_type, it)
activePlugin.activePump.pumpDescription.fillFor(PumpType.getByDescription(it)) activePlugin.activePump.pumpDescription.fillFor(PumpType.getByDescription(it))
pumpSync.connectNewPump(endRunning = false) // do not end running TBRs, we call this only to accept data properly pumpSync.connectNewPump(endRunning = false) // do not end running TBRs, we call this only to accept data properly
aapsLogger.debug(LTag.CORE, "Changing pump type to $it") aapsLogger.debug(LTag.CORE, "Changing pump type to $it")

View file

@ -141,7 +141,7 @@ class ImportExportPrefsImpl @Inject constructor(
val n6 = Settings.Global.getString(context.contentResolver, "device_name") val n6 = Settings.Global.getString(context.contentResolver, "device_name")
// name provided (hopefully) by user // name provided (hopefully) by user
val patientName = sp.getString(info.nightscout.core.utils.R.string.key_patient_name, "") val patientName = sp.getString(app.aaps.core.utils.R.string.key_patient_name, "")
val defaultPatientName = rh.gs(app.aaps.core.ui.R.string.patient_name_default) val defaultPatientName = rh.gs(app.aaps.core.ui.R.string.patient_name_default)
// name we detect from OS // name we detect from OS
@ -150,7 +150,7 @@ class ImportExportPrefsImpl @Inject constructor(
} }
private fun askForMasterPass(activity: FragmentActivity, @StringRes canceledMsg: Int, then: ((password: String) -> Unit)) { private fun askForMasterPass(activity: FragmentActivity, @StringRes canceledMsg: Int, then: ((password: String) -> Unit)) {
passwordCheck.queryPassword(activity, app.aaps.core.ui.R.string.master_password, info.nightscout.core.utils.R.string.key_master_password, { password -> passwordCheck.queryPassword(activity, app.aaps.core.ui.R.string.master_password, app.aaps.core.utils.R.string.key_master_password, { password ->
then(password) then(password)
}, { }, {
ToastUtils.warnToast(activity, rh.gs(canceledMsg)) ToastUtils.warnToast(activity, rh.gs(canceledMsg))
@ -162,7 +162,7 @@ class ImportExportPrefsImpl @Inject constructor(
activity: FragmentActivity, @StringRes canceledMsg: Int, @StringRes passwordName: Int, @StringRes passwordExplanation: Int?, activity: FragmentActivity, @StringRes canceledMsg: Int, @StringRes passwordName: Int, @StringRes passwordExplanation: Int?,
@StringRes passwordWarning: Int?, then: ((password: String) -> Unit) @StringRes passwordWarning: Int?, then: ((password: String) -> Unit)
) { ) {
passwordCheck.queryAnyPassword(activity, passwordName, info.nightscout.core.utils.R.string.key_master_password, passwordExplanation, passwordWarning, { password -> passwordCheck.queryAnyPassword(activity, passwordName, app.aaps.core.utils.R.string.key_master_password, passwordExplanation, passwordWarning, { password ->
then(password) then(password)
}, { }, {
ToastUtils.warnToast(activity, rh.gs(canceledMsg)) ToastUtils.warnToast(activity, rh.gs(canceledMsg))
@ -175,7 +175,7 @@ class ImportExportPrefsImpl @Inject constructor(
} }
private fun assureMasterPasswordSet(activity: FragmentActivity, @StringRes wrongPwdTitle: Int): Boolean { private fun assureMasterPasswordSet(activity: FragmentActivity, @StringRes wrongPwdTitle: Int): Boolean {
if (!sp.contains(info.nightscout.core.utils.R.string.key_master_password) || (sp.getString(info.nightscout.core.utils.R.string.key_master_password, "") == "")) { if (!sp.contains(app.aaps.core.utils.R.string.key_master_password) || (sp.getString(app.aaps.core.utils.R.string.key_master_password, "") == "")) {
WarningDialog.showWarning(activity, WarningDialog.showWarning(activity,
rh.gs(wrongPwdTitle), rh.gs(wrongPwdTitle),
rh.gs(R.string.master_password_missing, rh.gs(R.string.configbuilder_general), rh.gs(R.string.protection)), rh.gs(R.string.master_password_missing, rh.gs(R.string.configbuilder_general), rh.gs(R.string.protection)),

View file

@ -105,7 +105,7 @@ class MaintenanceFragment : DaggerFragment() {
.subscribeBy( .subscribeBy(
onError = { aapsLogger.error("Error clearing databases", it) }, onError = { aapsLogger.error("Error clearing databases", it) },
onComplete = { onComplete = {
rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.utils.R.string.key_units))) rxBus.send(EventPreferenceChange(rh.gs(app.aaps.core.utils.R.string.key_units)))
runOnUiThread { activity.recreate() } runOnUiThread { activity.recreate() }
} }
) )

View file

@ -99,7 +99,7 @@ class PrefFileListProviderImpl @Inject constructor(
override fun listCustomWatchfaceFiles(): MutableList<CwfData> { override fun listCustomWatchfaceFiles(): MutableList<CwfData> {
val customWatchfaceFiles = mutableListOf<CwfData>() val customWatchfaceFiles = mutableListOf<CwfData>()
val customAwtchfaceAuthorization = sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_custom_watchface_autorization, false) val customAwtchfaceAuthorization = sp.getBoolean(app.aaps.core.utils.R.string.key_wear_custom_watchface_autorization, false)
exportsPath.walk().filter { it.isFile && it.name.endsWith(ZipWatchfaceFormat.CWF_EXTENTION) }.forEach { file -> exportsPath.walk().filter { it.isFile && it.name.endsWith(ZipWatchfaceFormat.CWF_EXTENTION) }.forEach { file ->
ZipWatchfaceFormat.loadCustomWatchface(ZipInputStream(file.inputStream()), file.name, customAwtchfaceAuthorization)?.also { customWatchface -> ZipWatchfaceFormat.loadCustomWatchface(ZipInputStream(file.inputStream()), file.name, customAwtchfaceAuthorization)?.also { customWatchface ->
customWatchfaceFiles.add(customWatchface) customWatchfaceFiles.add(customWatchface)

View file

@ -107,7 +107,7 @@ class CustomWatchfaceImportListActivity : TranslatedDaggerAppCompatActivity() {
val colorAttr = if (checkCustomVersion(metadata)) app.aaps.core.ui.R.attr.metadataTextOkColor else app.aaps.core.ui.R.attr.metadataTextWarningColor val colorAttr = if (checkCustomVersion(metadata)) app.aaps.core.ui.R.attr.metadataTextOkColor else app.aaps.core.ui.R.attr.metadataTextWarningColor
cwfVersion.setTextColor(rh.gac(cwfVersion.context, colorAttr)) cwfVersion.setTextColor(rh.gac(cwfVersion.context, colorAttr))
val prefExisting = metadata.keys.any { it.isPref } val prefExisting = metadata.keys.any { it.isPref }
val prefSetting = sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_custom_watchface_autorization, false) val prefSetting = sp.getBoolean(app.aaps.core.utils.R.string.key_wear_custom_watchface_autorization, false)
val prefColor = if (prefSetting) app.aaps.core.ui.R.attr.metadataTextWarningColor else app.aaps.core.ui.R.attr.importListFileNameColor val prefColor = if (prefSetting) app.aaps.core.ui.R.attr.metadataTextWarningColor else app.aaps.core.ui.R.attr.importListFileNameColor
prefWarning.visibility = (prefExisting && prefSetting).toVisibility() prefWarning.visibility = (prefExisting && prefSetting).toVisibility()
prefInfo.visibility = (prefExisting && !prefSetting).toVisibility() prefInfo.visibility = (prefExisting && !prefSetting).toVisibility()

View file

@ -114,17 +114,17 @@ class SWDefinition @Inject constructor(
.add( .add(
SWRadioButton(injector) SWRadioButton(injector)
.option(R.array.unitsArray, R.array.unitsValues) .option(R.array.unitsArray, R.array.unitsValues)
.preferenceId(info.nightscout.core.utils.R.string.key_units).label(R.string.units) .preferenceId(app.aaps.core.utils.R.string.key_units).label(R.string.units)
.comment(R.string.setupwizard_units_prompt) .comment(R.string.setupwizard_units_prompt)
) )
.validator { sp.contains(info.nightscout.core.utils.R.string.key_units) } .validator { sp.contains(app.aaps.core.utils.R.string.key_units) }
private val displaySettings private val displaySettings
get() = SWScreen(injector, R.string.display_settings) get() = SWScreen(injector, R.string.display_settings)
.skippable(false) .skippable(false)
.add( .add(
SWEditNumberWithUnits(injector, Constants.LOW_MARK * Constants.MGDL_TO_MMOLL, 3.0, 8.0) SWEditNumberWithUnits(injector, Constants.LOW_MARK * Constants.MGDL_TO_MMOLL, 3.0, 8.0)
.preferenceId(info.nightscout.core.utils.R.string.key_low_mark) .preferenceId(app.aaps.core.utils.R.string.key_low_mark)
.updateDelay(5) .updateDelay(5)
.label(R.string.low_mark) .label(R.string.low_mark)
.comment(R.string.low_mark_comment) .comment(R.string.low_mark_comment)
@ -132,7 +132,7 @@ class SWDefinition @Inject constructor(
.add(SWBreak(injector)) .add(SWBreak(injector))
.add( .add(
SWEditNumberWithUnits(injector, Constants.HIGH_MARK * Constants.MGDL_TO_MMOLL, 5.0, 20.0) SWEditNumberWithUnits(injector, Constants.HIGH_MARK * Constants.MGDL_TO_MMOLL, 5.0, 20.0)
.preferenceId(info.nightscout.core.utils.R.string.key_high_mark) .preferenceId(app.aaps.core.utils.R.string.key_high_mark)
.updateDelay(5) .updateDelay(5)
.label(R.string.high_mark) .label(R.string.high_mark)
.comment(R.string.high_mark_comment) .comment(R.string.high_mark_comment)
@ -207,7 +207,7 @@ class SWDefinition @Inject constructor(
get() = SWScreen(injector, R.string.patient_name) get() = SWScreen(injector, R.string.patient_name)
.skippable(true) .skippable(true)
.add(SWInfoText(injector).label(R.string.patient_name_summary)) .add(SWInfoText(injector).label(R.string.patient_name_summary))
.add(SWEditString(injector).validator(String::isNotEmpty).preferenceId(info.nightscout.core.utils.R.string.key_patient_name)) .add(SWEditString(injector).validator(String::isNotEmpty).preferenceId(app.aaps.core.utils.R.string.key_patient_name))
private val privacy private val privacy
get() = SWScreen(injector, R.string.privacy_settings) get() = SWScreen(injector, R.string.privacy_settings)
@ -219,10 +219,10 @@ class SWDefinition @Inject constructor(
get() = SWScreen(injector, app.aaps.core.ui.R.string.master_password) get() = SWScreen(injector, app.aaps.core.ui.R.string.master_password)
.skippable(false) .skippable(false)
.add(SWInfoText(injector).label(app.aaps.core.ui.R.string.master_password)) .add(SWInfoText(injector).label(app.aaps.core.ui.R.string.master_password))
.add(SWEditEncryptedPassword(injector, cryptoUtil).preferenceId(info.nightscout.core.utils.R.string.key_master_password)) .add(SWEditEncryptedPassword(injector, cryptoUtil).preferenceId(app.aaps.core.utils.R.string.key_master_password))
.add(SWBreak(injector)) .add(SWBreak(injector))
.add(SWInfoText(injector).label(R.string.master_password_summary)) .add(SWInfoText(injector).label(R.string.master_password_summary))
.validator { !cryptoUtil.checkPassword("", sp.getString(info.nightscout.core.utils.R.string.key_master_password, "")) } .validator { !cryptoUtil.checkPassword("", sp.getString(app.aaps.core.utils.R.string.key_master_password, "")) }
private val screenAge private val screenAge
get() = SWScreen(injector, app.aaps.core.ui.R.string.patient_type) get() = SWScreen(injector, app.aaps.core.ui.R.string.patient_type)
@ -230,30 +230,30 @@ class SWDefinition @Inject constructor(
.add(SWBreak(injector)) .add(SWBreak(injector))
.add( .add(
SWRadioButton(injector) SWRadioButton(injector)
.option(app.aaps.core.ui.R.array.ageArray, info.nightscout.core.utils.R.array.ageValues) .option(app.aaps.core.ui.R.array.ageArray, app.aaps.core.utils.R.array.ageValues)
.preferenceId(info.nightscout.core.utils.R.string.key_age) .preferenceId(app.aaps.core.utils.R.string.key_age)
.label(app.aaps.core.ui.R.string.patient_type) .label(app.aaps.core.ui.R.string.patient_type)
.comment(app.aaps.core.ui.R.string.patient_age_summary) .comment(app.aaps.core.ui.R.string.patient_age_summary)
) )
.add(SWBreak(injector)) .add(SWBreak(injector))
.add( .add(
SWEditNumber(injector, 3.0, 0.1, 25.0) SWEditNumber(injector, 3.0, 0.1, 25.0)
.preferenceId(info.nightscout.core.utils.R.string.key_treatmentssafety_maxbolus) .preferenceId(app.aaps.core.utils.R.string.key_treatmentssafety_maxbolus)
.updateDelay(5) .updateDelay(5)
.label(app.aaps.core.ui.R.string.max_bolus_title) .label(app.aaps.core.ui.R.string.max_bolus_title)
.comment(R.string.common_values) .comment(R.string.common_values)
) )
.add( .add(
SWEditIntNumber(injector, 48, 1, 100) SWEditIntNumber(injector, 48, 1, 100)
.preferenceId(info.nightscout.core.utils.R.string.key_treatmentssafety_maxcarbs) .preferenceId(app.aaps.core.utils.R.string.key_treatmentssafety_maxcarbs)
.updateDelay(5) .updateDelay(5)
.label(app.aaps.core.ui.R.string.max_carbs_title) .label(app.aaps.core.ui.R.string.max_carbs_title)
.comment(R.string.common_values) .comment(R.string.common_values)
) )
.validator { .validator {
sp.contains(info.nightscout.core.utils.R.string.key_age) sp.contains(app.aaps.core.utils.R.string.key_age)
&& sp.getDouble(info.nightscout.core.utils.R.string.key_treatmentssafety_maxbolus, 0.0) > 0 && sp.getDouble(app.aaps.core.utils.R.string.key_treatmentssafety_maxbolus, 0.0) > 0
&& sp.getInt(info.nightscout.core.utils.R.string.key_treatmentssafety_maxcarbs, 0) > 0 && sp.getInt(app.aaps.core.utils.R.string.key_treatmentssafety_maxcarbs, 0) > 0
} }
private val screenInsulin private val screenInsulin
@ -354,10 +354,10 @@ class SWDefinition @Inject constructor(
.add( .add(
SWRadioButton(injector) SWRadioButton(injector)
.option(app.aaps.core.ui.R.array.aps_modeArray, app.aaps.core.ui.R.array.aps_modeValues) .option(app.aaps.core.ui.R.array.aps_modeArray, app.aaps.core.ui.R.array.aps_modeValues)
.preferenceId(info.nightscout.core.utils.R.string.key_aps_mode).label(R.string.apsmode_title) .preferenceId(app.aaps.core.utils.R.string.key_aps_mode).label(R.string.apsmode_title)
.comment(R.string.setupwizard_preferred_aps_mode) .comment(R.string.setupwizard_preferred_aps_mode)
) )
.validator { sp.contains(info.nightscout.core.utils.R.string.key_aps_mode) } .validator { sp.contains(app.aaps.core.utils.R.string.key_aps_mode) }
private val screenLoop private val screenLoop
get() = SWScreen(injector, R.string.configbuilder_loop) get() = SWScreen(injector, R.string.configbuilder_loop)

View file

@ -26,13 +26,13 @@ class SWEditEncryptedPassword(injector: HasAndroidInjector, private val cryptoUt
override fun generateDialog(layout: LinearLayout) { override fun generateDialog(layout: LinearLayout) {
val context = layout.context val context = layout.context
val isPasswordSet = sp.contains(info.nightscout.core.utils.R.string.key_master_password) && sp.getString(info.nightscout.core.utils.R.string.key_master_password, "") != "" val isPasswordSet = sp.contains(app.aaps.core.utils.R.string.key_master_password) && sp.getString(app.aaps.core.utils.R.string.key_master_password, "") != ""
button = Button(context) button = Button(context)
button?.setText(app.aaps.core.ui.R.string.unlock_settings) button?.setText(app.aaps.core.ui.R.string.unlock_settings)
button?.setOnClickListener { button?.setOnClickListener {
scanForActivity(context)?.let { activity -> scanForActivity(context)?.let { activity ->
passwordCheck.queryPassword(activity, app.aaps.core.ui.R.string.master_password, info.nightscout.core.utils.R.string.key_master_password, { passwordCheck.queryPassword(activity, app.aaps.core.ui.R.string.master_password, app.aaps.core.utils.R.string.key_master_password, {
button?.visibility = View.GONE button?.visibility = View.GONE
editText?.visibility = View.VISIBLE editText?.visibility = View.VISIBLE
editText2?.visibility = View.VISIBLE editText2?.visibility = View.VISIBLE

View file

@ -87,16 +87,16 @@ class ObjectivesPlugin @Inject constructor(
objective.startedOn = 0 objective.startedOn = 0
objective.accomplishedOn = 0 objective.accomplishedOn = 0
} }
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectives_bg_is_available_in_ns, false) sp.putBoolean(app.aaps.core.utils.R.string.key_objectives_bg_is_available_in_ns, false)
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectives_pump_status_is_available_in_ns, false) sp.putBoolean(app.aaps.core.utils.R.string.key_objectives_pump_status_is_available_in_ns, false)
sp.putInt(info.nightscout.core.utils.R.string.key_ObjectivesmanualEnacts, 0) sp.putInt(app.aaps.core.utils.R.string.key_ObjectivesmanualEnacts, 0)
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectiveuseprofileswitch, false) sp.putBoolean(app.aaps.core.utils.R.string.key_objectiveuseprofileswitch, false)
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectiveusedisconnect, false) sp.putBoolean(app.aaps.core.utils.R.string.key_objectiveusedisconnect, false)
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectiveusereconnect, false) sp.putBoolean(app.aaps.core.utils.R.string.key_objectiveusereconnect, false)
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectiveusetemptarget, false) sp.putBoolean(app.aaps.core.utils.R.string.key_objectiveusetemptarget, false)
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectiveuseactions, false) sp.putBoolean(app.aaps.core.utils.R.string.key_objectiveuseactions, false)
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectiveuseloop, false) sp.putBoolean(app.aaps.core.utils.R.string.key_objectiveuseloop, false)
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectiveusescale, false) sp.putBoolean(app.aaps.core.utils.R.string.key_objectiveusescale, false)
} }
fun allPriorAccomplished(position: Int): Boolean { fun allPriorAccomplished(position: Int): Boolean {

View file

@ -24,7 +24,7 @@ class Objective0(injector: HasAndroidInjector) : Objective(injector, "config", R
init { init {
tasks.add(object : Task(this, R.string.objectives_bgavailableinns) { tasks.add(object : Task(this, R.string.objectives_bgavailableinns) {
override fun isCompleted(): Boolean { override fun isCompleted(): Boolean {
return sp.getBoolean(info.nightscout.core.utils.R.string.key_objectives_bg_is_available_in_ns, false) || tidepoolPlugin?.hasWritePermission == true return sp.getBoolean(app.aaps.core.utils.R.string.key_objectives_bg_is_available_in_ns, false) || tidepoolPlugin?.hasWritePermission == true
} }
}) })
tasks.add(object : Task(this, R.string.synchaswritepermission) { tasks.add(object : Task(this, R.string.synchaswritepermission) {
@ -34,7 +34,7 @@ class Objective0(injector: HasAndroidInjector) : Objective(injector, "config", R
}) })
tasks.add(object : Task(this, app.aaps.core.ui.R.string.virtualpump_uploadstatus_title) { tasks.add(object : Task(this, app.aaps.core.ui.R.string.virtualpump_uploadstatus_title) {
override fun isCompleted(): Boolean { override fun isCompleted(): Boolean {
return sp.getBoolean(info.nightscout.core.utils.R.string.key_virtual_pump_upload_status, false) || tidepoolPlugin?.hasWritePermission == true return sp.getBoolean(app.aaps.core.utils.R.string.key_virtual_pump_upload_status, false) || tidepoolPlugin?.hasWritePermission == true
} }
override fun shouldBeIgnored(): Boolean { override fun shouldBeIgnored(): Boolean {
@ -44,7 +44,7 @@ class Objective0(injector: HasAndroidInjector) : Objective(injector, "config", R
tasks.add( tasks.add(
object : Task(this, R.string.objectives_pumpstatusavailableinns) { object : Task(this, R.string.objectives_pumpstatusavailableinns) {
override fun isCompleted(): Boolean { override fun isCompleted(): Boolean {
return sp.getBoolean(info.nightscout.core.utils.R.string.key_objectives_pump_status_is_available_in_ns, false) || tidepoolPlugin?.hasWritePermission == true return sp.getBoolean(app.aaps.core.utils.R.string.key_objectives_pump_status_is_available_in_ns, false) || tidepoolPlugin?.hasWritePermission == true
} }
}.learned(Learned(R.string.objectives_0_learned)) }.learned(Learned(R.string.objectives_0_learned))
) )

View file

@ -15,38 +15,38 @@ class Objective1 @Inject constructor(injector: HasAndroidInjector) : Objective(i
init { init {
tasks.add(object : Task(this, R.string.objectives_useprofileswitch) { tasks.add(object : Task(this, R.string.objectives_useprofileswitch) {
override fun isCompleted(): Boolean { override fun isCompleted(): Boolean {
return sp.getBoolean(info.nightscout.core.utils.R.string.key_objectiveuseprofileswitch, false) return sp.getBoolean(app.aaps.core.utils.R.string.key_objectiveuseprofileswitch, false)
} }
}) })
tasks.add(object : Task(this, R.string.objectives_usedisconnectpump) { tasks.add(object : Task(this, R.string.objectives_usedisconnectpump) {
override fun isCompleted(): Boolean { override fun isCompleted(): Boolean {
return sp.getBoolean(info.nightscout.core.utils.R.string.key_objectiveusedisconnect, false) return sp.getBoolean(app.aaps.core.utils.R.string.key_objectiveusedisconnect, false)
} }
}.hint(Hint(R.string.disconnectpump_hint))) }.hint(Hint(R.string.disconnectpump_hint)))
tasks.add(object : Task(this, R.string.objectives_usereconnectpump) { tasks.add(object : Task(this, R.string.objectives_usereconnectpump) {
override fun isCompleted(): Boolean { override fun isCompleted(): Boolean {
return sp.getBoolean(info.nightscout.core.utils.R.string.key_objectiveusereconnect, false) return sp.getBoolean(app.aaps.core.utils.R.string.key_objectiveusereconnect, false)
} }
}.hint(Hint(R.string.disconnectpump_hint))) }.hint(Hint(R.string.disconnectpump_hint)))
tasks.add(object : Task(this, R.string.objectives_usetemptarget) { tasks.add(object : Task(this, R.string.objectives_usetemptarget) {
override fun isCompleted(): Boolean { override fun isCompleted(): Boolean {
return sp.getBoolean(info.nightscout.core.utils.R.string.key_objectiveusetemptarget, false) return sp.getBoolean(app.aaps.core.utils.R.string.key_objectiveusetemptarget, false)
} }
}.hint(Hint(R.string.usetemptarget_hint))) }.hint(Hint(R.string.usetemptarget_hint)))
tasks.add(object : Task(this, R.string.objectives_useactions) { tasks.add(object : Task(this, R.string.objectives_useactions) {
override fun isCompleted(): Boolean { override fun isCompleted(): Boolean {
return sp.getBoolean(info.nightscout.core.utils.R.string.key_objectiveuseactions, false) && actionsPlugin.isEnabled() && actionsPlugin.isFragmentVisible() return sp.getBoolean(app.aaps.core.utils.R.string.key_objectiveuseactions, false) && actionsPlugin.isEnabled() && actionsPlugin.isFragmentVisible()
} }
}.hint(Hint(R.string.useaction_hint))) }.hint(Hint(R.string.useaction_hint)))
tasks.add(object : Task(this, R.string.objectives_useloop) { tasks.add(object : Task(this, R.string.objectives_useloop) {
override fun isCompleted(): Boolean { override fun isCompleted(): Boolean {
return sp.getBoolean(info.nightscout.core.utils.R.string.key_objectiveuseloop, false) return sp.getBoolean(app.aaps.core.utils.R.string.key_objectiveuseloop, false)
} }
}.hint(Hint(R.string.useaction_hint))) }.hint(Hint(R.string.useaction_hint)))
tasks.add( tasks.add(
object : Task(this, R.string.objectives_usescale) { object : Task(this, R.string.objectives_usescale) {
override fun isCompleted(): Boolean { override fun isCompleted(): Boolean {
return sp.getBoolean(info.nightscout.core.utils.R.string.key_objectiveusescale, false) return sp.getBoolean(app.aaps.core.utils.R.string.key_objectiveusescale, false)
} }
}.hint(Hint(R.string.usescale_hint)) }.hint(Hint(R.string.usescale_hint))
.learned(Learned(R.string.objectives_usage_learned)) .learned(Learned(R.string.objectives_usage_learned))

View file

@ -16,14 +16,14 @@ class Objective3 @Inject constructor(injector: HasAndroidInjector) : Objective(i
tasks.add( tasks.add(
object : Task(this, R.string.objectives_manualenacts) { object : Task(this, R.string.objectives_manualenacts) {
override fun isCompleted(): Boolean { override fun isCompleted(): Boolean {
return sp.getInt(info.nightscout.core.utils.R.string.key_ObjectivesmanualEnacts, 0) >= MANUAL_ENACTS_NEEDED return sp.getInt(app.aaps.core.utils.R.string.key_ObjectivesmanualEnacts, 0) >= MANUAL_ENACTS_NEEDED
} }
override val progress: String override val progress: String
get() = get() =
if (sp.getInt(info.nightscout.core.utils.R.string.key_ObjectivesmanualEnacts, 0) >= MANUAL_ENACTS_NEEDED) if (sp.getInt(app.aaps.core.utils.R.string.key_ObjectivesmanualEnacts, 0) >= MANUAL_ENACTS_NEEDED)
rh.gs(R.string.completed_well_done) rh.gs(R.string.completed_well_done)
else sp.getInt(info.nightscout.core.utils.R.string.key_ObjectivesmanualEnacts, 0).toString() + " / " + MANUAL_ENACTS_NEEDED else sp.getInt(app.aaps.core.utils.R.string.key_ObjectivesmanualEnacts, 0).toString() + " / " + MANUAL_ENACTS_NEEDED
}.learned(Learned(R.string.objectives_openloop_learned)) }.learned(Learned(R.string.objectives_openloop_learned))
) )
} }

View file

@ -16,7 +16,7 @@ class Objective6(injector: HasAndroidInjector) : Objective(injector, "maxiob", R
tasks.add(MinimumDurationTask(this, T.days(1).msecs())) tasks.add(MinimumDurationTask(this, T.days(1).msecs()))
tasks.add( tasks.add(
object : Task(this, R.string.closedmodeenabled) { object : Task(this, R.string.closedmodeenabled) {
override fun isCompleted(): Boolean = ApsMode.fromString(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)) == ApsMode.CLOSED override fun isCompleted(): Boolean = ApsMode.fromString(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)) == ApsMode.CLOSED
}) })
tasks.add( tasks.add(
object : Task(this, R.string.maxiobset) { object : Task(this, R.string.maxiobset) {

View file

@ -69,7 +69,7 @@ class SafetyPlugin @Inject constructor(
} }
override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> { override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
val mode = ApsMode.fromString(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)) val mode = ApsMode.fromString(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name))
if (mode == ApsMode.OPEN) value.set(false, rh.gs(R.string.closedmodedisabledinpreferences), this) if (mode == ApsMode.OPEN) value.set(false, rh.gs(R.string.closedmodedisabledinpreferences), this)
if (!config.isEngineeringModeOrRelease()) { if (!config.isEngineeringModeOrRelease()) {
if (value.value()) { if (value.value()) {
@ -139,7 +139,7 @@ class SafetyPlugin @Inject constructor(
override fun applyBolusConstraints(insulin: Constraint<Double>): Constraint<Double> { override fun applyBolusConstraints(insulin: Constraint<Double>): Constraint<Double> {
insulin.setIfGreater(0.0, rh.gs(app.aaps.core.ui.R.string.limitingbolus, 0.0, rh.gs(app.aaps.core.ui.R.string.itmustbepositivevalue)), this) insulin.setIfGreater(0.0, rh.gs(app.aaps.core.ui.R.string.limitingbolus, 0.0, rh.gs(app.aaps.core.ui.R.string.itmustbepositivevalue)), this)
val maxBolus = sp.getDouble(info.nightscout.core.utils.R.string.key_treatmentssafety_maxbolus, 3.0) val maxBolus = sp.getDouble(app.aaps.core.utils.R.string.key_treatmentssafety_maxbolus, 3.0)
insulin.setIfSmaller(maxBolus, rh.gs(app.aaps.core.ui.R.string.limitingbolus, maxBolus, rh.gs(R.string.maxvalueinpreferences)), this) insulin.setIfSmaller(maxBolus, rh.gs(app.aaps.core.ui.R.string.limitingbolus, maxBolus, rh.gs(R.string.maxvalueinpreferences)), this)
insulin.setIfSmaller(hardLimits.maxBolus(), rh.gs(app.aaps.core.ui.R.string.limitingbolus, hardLimits.maxBolus(), rh.gs(R.string.hardlimit)), this) insulin.setIfSmaller(hardLimits.maxBolus(), rh.gs(app.aaps.core.ui.R.string.limitingbolus, hardLimits.maxBolus(), rh.gs(R.string.hardlimit)), this)
val pump = activePlugin.activePump val pump = activePlugin.activePump
@ -150,7 +150,7 @@ class SafetyPlugin @Inject constructor(
override fun applyExtendedBolusConstraints(insulin: Constraint<Double>): Constraint<Double> { override fun applyExtendedBolusConstraints(insulin: Constraint<Double>): Constraint<Double> {
insulin.setIfGreater(0.0, rh.gs(R.string.limitingextendedbolus, 0.0, rh.gs(app.aaps.core.ui.R.string.itmustbepositivevalue)), this) insulin.setIfGreater(0.0, rh.gs(R.string.limitingextendedbolus, 0.0, rh.gs(app.aaps.core.ui.R.string.itmustbepositivevalue)), this)
val maxBolus = sp.getDouble(info.nightscout.core.utils.R.string.key_treatmentssafety_maxbolus, 3.0) val maxBolus = sp.getDouble(app.aaps.core.utils.R.string.key_treatmentssafety_maxbolus, 3.0)
insulin.setIfSmaller(maxBolus, rh.gs(R.string.limitingextendedbolus, maxBolus, rh.gs(R.string.maxvalueinpreferences)), this) insulin.setIfSmaller(maxBolus, rh.gs(R.string.limitingextendedbolus, maxBolus, rh.gs(R.string.maxvalueinpreferences)), this)
insulin.setIfSmaller(hardLimits.maxBolus(), rh.gs(R.string.limitingextendedbolus, hardLimits.maxBolus(), rh.gs(R.string.hardlimit)), this) insulin.setIfSmaller(hardLimits.maxBolus(), rh.gs(R.string.limitingextendedbolus, hardLimits.maxBolus(), rh.gs(R.string.hardlimit)), this)
val pump = activePlugin.activePump val pump = activePlugin.activePump
@ -161,13 +161,13 @@ class SafetyPlugin @Inject constructor(
override fun applyCarbsConstraints(carbs: Constraint<Int>): Constraint<Int> { override fun applyCarbsConstraints(carbs: Constraint<Int>): Constraint<Int> {
carbs.setIfGreater(0, rh.gs(R.string.limitingcarbs, 0, rh.gs(app.aaps.core.ui.R.string.itmustbepositivevalue)), this) carbs.setIfGreater(0, rh.gs(R.string.limitingcarbs, 0, rh.gs(app.aaps.core.ui.R.string.itmustbepositivevalue)), this)
val maxCarbs = sp.getInt(info.nightscout.core.utils.R.string.key_treatmentssafety_maxcarbs, 48) val maxCarbs = sp.getInt(app.aaps.core.utils.R.string.key_treatmentssafety_maxcarbs, 48)
carbs.setIfSmaller(maxCarbs, rh.gs(R.string.limitingcarbs, maxCarbs, rh.gs(R.string.maxvalueinpreferences)), this) carbs.setIfSmaller(maxCarbs, rh.gs(R.string.limitingcarbs, maxCarbs, rh.gs(R.string.maxvalueinpreferences)), this)
return carbs return carbs
} }
override fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> { override fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> {
val apsMode = ApsMode.fromString(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)) val apsMode = ApsMode.fromString(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name))
if (apsMode == ApsMode.LGS) maxIob.setIfSmaller( if (apsMode == ApsMode.LGS) maxIob.setIfSmaller(
HardLimits.MAX_IOB_LGS, HardLimits.MAX_IOB_LGS,
rh.gs(app.aaps.core.ui.R.string.limiting_iob, HardLimits.MAX_IOB_LGS, rh.gs(app.aaps.core.ui.R.string.lowglucosesuspend)), rh.gs(app.aaps.core.ui.R.string.limiting_iob, HardLimits.MAX_IOB_LGS, rh.gs(app.aaps.core.ui.R.string.lowglucosesuspend)),
@ -178,13 +178,13 @@ class SafetyPlugin @Inject constructor(
override fun configuration(): JSONObject = override fun configuration(): JSONObject =
JSONObject() JSONObject()
.putString(info.nightscout.core.utils.R.string.key_age, sp, rh) .putString(app.aaps.core.utils.R.string.key_age, sp, rh)
.putDouble(info.nightscout.core.utils.R.string.key_treatmentssafety_maxbolus, sp, rh) .putDouble(app.aaps.core.utils.R.string.key_treatmentssafety_maxbolus, sp, rh)
.putInt(info.nightscout.core.utils.R.string.key_treatmentssafety_maxcarbs, sp, rh) .putInt(app.aaps.core.utils.R.string.key_treatmentssafety_maxcarbs, sp, rh)
override fun applyConfiguration(configuration: JSONObject) { override fun applyConfiguration(configuration: JSONObject) {
configuration.storeString(info.nightscout.core.utils.R.string.key_age, sp, rh) configuration.storeString(app.aaps.core.utils.R.string.key_age, sp, rh)
configuration.storeDouble(info.nightscout.core.utils.R.string.key_treatmentssafety_maxbolus, sp, rh) configuration.storeDouble(app.aaps.core.utils.R.string.key_treatmentssafety_maxbolus, sp, rh)
configuration.storeInt(info.nightscout.core.utils.R.string.key_treatmentssafety_maxcarbs, sp, rh) configuration.storeInt(app.aaps.core.utils.R.string.key_treatmentssafety_maxcarbs, sp, rh)
} }
} }

View file

@ -65,7 +65,7 @@ class VersionCheckerPlugin @Inject constructor(
versionCheckerUtils.triggerCheckVersion() versionCheckerUtils.triggerCheckVersion()
if (lastCheckOlderThan(gracePeriod.veryOld.daysToMillis())) if (lastCheckOlderThan(gracePeriod.veryOld.daysToMillis()))
value.set(false, rh.gs(R.string.very_old_version), this) value.set(false, rh.gs(R.string.very_old_version), this)
val endDate = sp.getLong(rh.gs(info.nightscout.core.utils.R.string.key_app_expiration) + "_" + config.VERSION_NAME, 0) val endDate = sp.getLong(rh.gs(app.aaps.core.utils.R.string.key_app_expiration) + "_" + config.VERSION_NAME, 0)
if (endDate != 0L && dateUtil.now() > endDate) if (endDate != 0L && dateUtil.now() > endDate)
value.set(false, rh.gs(R.string.application_expired), this) value.set(false, rh.gs(R.string.application_expired), this)
return value return value
@ -99,7 +99,7 @@ class VersionCheckerPlugin @Inject constructor(
uiInteraction.addNotification(Notification.OLD_VERSION, message, Notification.NORMAL) uiInteraction.addNotification(Notification.OLD_VERSION, message, Notification.NORMAL)
} }
val endDate = sp.getLong(rh.gs(info.nightscout.core.utils.R.string.key_app_expiration) + "_" + config.VERSION_NAME, 0) val endDate = sp.getLong(rh.gs(app.aaps.core.utils.R.string.key_app_expiration) + "_" + config.VERSION_NAME, 0)
if (endDate != 0L && dateUtil.now() > endDate && shouldWarnAgain()) { if (endDate != 0L && dateUtil.now() > endDate && shouldWarnAgain()) {
// store last notification time // store last notification time
sp.putLong(R.string.key_last_versionchecker_plugin_warning_timestamp, now) sp.putLong(R.string.key_last_versionchecker_plugin_warning_timestamp, now)

View file

@ -55,11 +55,11 @@ class VersionCheckerUtilsImpl @Inject constructor(
compareWithCurrentVersion(version, config.get().VERSION_NAME) compareWithCurrentVersion(version, config.get().VERSION_NAME)
// App expiration // App expiration
var endDate = sp.getLong(rh.gs(info.nightscout.core.utils.R.string.key_app_expiration) + "_" + config.get().VERSION_NAME, 0) var endDate = sp.getLong(rh.gs(app.aaps.core.utils.R.string.key_app_expiration) + "_" + config.get().VERSION_NAME, 0)
AllowedVersions().findByVersion(definition, config.get().VERSION_NAME)?.let { expirationJson -> AllowedVersions().findByVersion(definition, config.get().VERSION_NAME)?.let { expirationJson ->
AllowedVersions().endDateToMilliseconds(expirationJson.getString("endDate"))?.let { ed -> AllowedVersions().endDateToMilliseconds(expirationJson.getString("endDate"))?.let { ed ->
endDate = ed + T.days(1).msecs() endDate = ed + T.days(1).msecs()
sp.putLong(rh.gs(info.nightscout.core.utils.R.string.key_app_expiration) + "_" + config.get().VERSION_NAME, endDate) sp.putLong(rh.gs(app.aaps.core.utils.R.string.key_app_expiration) + "_" + config.get().VERSION_NAME, endDate)
} }
} }
if (endDate != 0L) onExpireDateDetected(config.get().VERSION_NAME, dateUtil.dateString(endDate)) if (endDate != 0L) onExpireDateDetected(config.get().VERSION_NAME, dateUtil.dateString(endDate))

View file

@ -109,7 +109,7 @@ class ConstraintsCheckerImplTest : TestBaseWithProfile() {
`when`(rh.gs(app.aaps.core.ui.R.string.pumplimit)).thenReturn("pump limit") `when`(rh.gs(app.aaps.core.ui.R.string.pumplimit)).thenReturn("pump limit")
`when`(rh.gs(app.aaps.core.ui.R.string.limitingbolus)).thenReturn("Limiting bolus to %.1f U because of %s") `when`(rh.gs(app.aaps.core.ui.R.string.limitingbolus)).thenReturn("Limiting bolus to %.1f U because of %s")
`when`(rh.gs(app.aaps.plugins.constraints.R.string.hardlimit)).thenReturn("hard limit") `when`(rh.gs(app.aaps.plugins.constraints.R.string.hardlimit)).thenReturn("hard limit")
`when`(rh.gs(info.nightscout.core.utils.R.string.key_child)).thenReturn("child") `when`(rh.gs(app.aaps.core.utils.R.string.key_child)).thenReturn("child")
`when`(rh.gs(app.aaps.plugins.constraints.R.string.limitingcarbs)).thenReturn("Limiting carbs to %d g because of %s") `when`(rh.gs(app.aaps.plugins.constraints.R.string.limitingcarbs)).thenReturn("Limiting carbs to %d g because of %s")
`when`(rh.gs(app.aaps.plugins.aps.R.string.limiting_iob)).thenReturn("Limiting IOB to %.1f U because of %s") `when`(rh.gs(app.aaps.plugins.aps.R.string.limiting_iob)).thenReturn("Limiting IOB to %.1f U because of %s")
`when`(rh.gs(app.aaps.core.ui.R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s") `when`(rh.gs(app.aaps.core.ui.R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
@ -243,13 +243,13 @@ class ConstraintsCheckerImplTest : TestBaseWithProfile() {
// 2x Safety & Objectives // 2x Safety & Objectives
@Test @Test
fun isClosedLoopAllowedTest() { fun isClosedLoopAllowedTest() {
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name) `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
objectivesPlugin.objectives[Objectives.MAXIOB_ZERO_CL_OBJECTIVE].startedOn = 0 objectivesPlugin.objectives[Objectives.MAXIOB_ZERO_CL_OBJECTIVE].startedOn = 0
var c: Constraint<Boolean> = constraintChecker.isClosedLoopAllowed() var c: Constraint<Boolean> = constraintChecker.isClosedLoopAllowed()
aapsLogger.debug("Reason list: " + c.reasonList.toString()) aapsLogger.debug("Reason list: " + c.reasonList.toString())
// assertThat(c.reasonList[0].toString()).contains("Closed loop is disabled") // Safety & Objectives // assertThat(c.reasonList[0].toString()).contains("Closed loop is disabled") // Safety & Objectives
assertThat(c.value()).isFalse() assertThat(c.value()).isFalse()
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name) `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name)
c = constraintChecker.isClosedLoopAllowed() c = constraintChecker.isClosedLoopAllowed()
assertThat(c.reasonList[0]).contains("Closed loop mode disabled in preferences") // Safety & Objectives assertThat(c.reasonList[0]).contains("Closed loop mode disabled in preferences") // Safety & Objectives
// assertThat(c.reasonList).hasThat(3) // 2x Safety & Objectives // assertThat(c.reasonList).hasThat(3) // 2x Safety & Objectives
@ -261,7 +261,7 @@ class ConstraintsCheckerImplTest : TestBaseWithProfile() {
fun isAutosensModeEnabledTest() { fun isAutosensModeEnabledTest() {
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true) openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
objectivesPlugin.objectives[Objectives.AUTOSENS_OBJECTIVE].startedOn = 0 objectivesPlugin.objectives[Objectives.AUTOSENS_OBJECTIVE].startedOn = 0
`when`(sp.getBoolean(info.nightscout.core.utils.R.string.key_use_autosens, false)).thenReturn(false) `when`(sp.getBoolean(app.aaps.core.utils.R.string.key_use_autosens, false)).thenReturn(false)
val c = constraintChecker.isAutosensModeEnabled() val c = constraintChecker.isAutosensModeEnabled()
assertThat(c.reasonList).hasSize(2) // Safety & Objectives assertThat(c.reasonList).hasSize(2) // Safety & Objectives
assertThat(c.mostLimitedReasonList).hasSize(2) // Safety & Objectives assertThat(c.mostLimitedReasonList).hasSize(2) // Safety & Objectives
@ -292,7 +292,7 @@ class ConstraintsCheckerImplTest : TestBaseWithProfile() {
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true) openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
objectivesPlugin.objectives[Objectives.SMB_OBJECTIVE].startedOn = 0 objectivesPlugin.objectives[Objectives.SMB_OBJECTIVE].startedOn = 0
`when`(sp.getBoolean(app.aaps.plugins.aps.R.string.key_use_smb, false)).thenReturn(false) `when`(sp.getBoolean(app.aaps.plugins.aps.R.string.key_use_smb, false)).thenReturn(false)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name) `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name)
// `when`(constraintChecker.isClosedLoopAllowed()).thenReturn(ConstraintObject(true)) // `when`(constraintChecker.isClosedLoopAllowed()).thenReturn(ConstraintObject(true))
val c = constraintChecker.isSMBModeEnabled() val c = constraintChecker.isSMBModeEnabled()
assertThat(c.reasonList).hasSize(3) // 2x Safety & Objectives assertThat(c.reasonList).hasSize(3) // 2x Safety & Objectives
@ -319,7 +319,7 @@ class ConstraintsCheckerImplTest : TestBaseWithProfile() {
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")
// Apply all limits // Apply all limits
val d = constraintChecker.getMaxBasalAllowed(validProfile) val d = constraintChecker.getMaxBasalAllowed(validProfile)
@ -346,7 +346,7 @@ class ConstraintsCheckerImplTest : TestBaseWithProfile() {
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")
// Apply all limits // Apply all limits
val i = constraintChecker.getMaxBasalPercentAllowed(validProfile) val i = constraintChecker.getMaxBasalPercentAllowed(validProfile)
@ -372,8 +372,8 @@ class ConstraintsCheckerImplTest : TestBaseWithProfile() {
// insightPlugin.setStatusResult(result); // insightPlugin.setStatusResult(result);
// No limit by default // No limit by default
`when`(sp.getDouble(info.nightscout.core.utils.R.string.key_treatmentssafety_maxbolus, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_treatmentssafety_maxbolus, 3.0)).thenReturn(3.0)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")
// Apply all limits // Apply all limits
val d = constraintChecker.getMaxBolusAllowed() val d = constraintChecker.getMaxBolusAllowed()
@ -386,7 +386,7 @@ class ConstraintsCheckerImplTest : TestBaseWithProfile() {
@Test @Test
fun carbsAmountShouldBeLimited() { fun carbsAmountShouldBeLimited() {
// No limit by default // No limit by default
`when`(sp.getInt(info.nightscout.core.utils.R.string.key_treatmentssafety_maxcarbs, 48)).thenReturn(48) `when`(sp.getInt(app.aaps.core.utils.R.string.key_treatmentssafety_maxcarbs, 48)).thenReturn(48)
// Apply all limits // Apply all limits
val i = constraintChecker.getMaxCarbsAllowed() val i = constraintChecker.getMaxCarbsAllowed()
@ -399,9 +399,9 @@ class ConstraintsCheckerImplTest : TestBaseWithProfile() {
@Test @Test
fun iobAMAShouldBeLimited() { fun iobAMAShouldBeLimited() {
// No limit by default // No limit by default
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name) `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("teenage") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("teenage")
openAPSAMAPlugin.setPluginEnabled(PluginType.APS, true) openAPSAMAPlugin.setPluginEnabled(PluginType.APS, true)
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, false) openAPSSMBPlugin.setPluginEnabled(PluginType.APS, false)
@ -415,9 +415,9 @@ class ConstraintsCheckerImplTest : TestBaseWithProfile() {
@Test @Test
fun iobSMBShouldBeLimited() { fun iobSMBShouldBeLimited() {
// No limit by default // No limit by default
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name) `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapssmb_max_iob, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapssmb_max_iob, 3.0)).thenReturn(3.0)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("teenage") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("teenage")
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true) openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
openAPSAMAPlugin.setPluginEnabled(PluginType.APS, false) openAPSAMAPlugin.setPluginEnabled(PluginType.APS, false)

View file

@ -68,7 +68,7 @@ class SafetyPluginTest : TestBaseWithProfile() {
`when`(rh.gs(app.aaps.plugins.constraints.R.string.closed_loop_disabled_on_dev_branch)).thenReturn("Running dev version. Closed loop is disabled.") `when`(rh.gs(app.aaps.plugins.constraints.R.string.closed_loop_disabled_on_dev_branch)).thenReturn("Running dev version. Closed loop is disabled.")
`when`(rh.gs(app.aaps.plugins.constraints.R.string.smbalwaysdisabled)).thenReturn("SMB always and after carbs disabled because active BG source doesn\\'t support advanced filtering") `when`(rh.gs(app.aaps.plugins.constraints.R.string.smbalwaysdisabled)).thenReturn("SMB always and after carbs disabled because active BG source doesn\\'t support advanced filtering")
`when`(rh.gs(app.aaps.plugins.constraints.R.string.smbnotallowedinopenloopmode)).thenReturn("SMB not allowed in open loop mode") `when`(rh.gs(app.aaps.plugins.constraints.R.string.smbnotallowedinopenloopmode)).thenReturn("SMB not allowed in open loop mode")
`when`(rh.gs(info.nightscout.core.utils.R.string.key_child)).thenReturn("child") `when`(rh.gs(app.aaps.core.utils.R.string.key_child)).thenReturn("child")
`when`(rh.gs(app.aaps.core.ui.R.string.lowglucosesuspend)).thenReturn("Low Glucose Suspend") `when`(rh.gs(app.aaps.core.ui.R.string.lowglucosesuspend)).thenReturn("Low Glucose Suspend")
`when`(activePlugin.activePump).thenReturn(virtualPumpPlugin) `when`(activePlugin.activePump).thenReturn(virtualPumpPlugin)
@ -95,7 +95,7 @@ class SafetyPluginTest : TestBaseWithProfile() {
@Test @Test
fun disabledEngineeringModeShouldLimitClosedLoop() { fun disabledEngineeringModeShouldLimitClosedLoop() {
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name) `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
`when`(config.isEngineeringModeOrRelease()).thenReturn(false) `when`(config.isEngineeringModeOrRelease()).thenReturn(false)
val c = safetyPlugin.isClosedLoopAllowed(ConstraintObject(true, aapsLogger)) val c = safetyPlugin.isClosedLoopAllowed(ConstraintObject(true, aapsLogger))
assertThat(c.getReasons()).contains("Running dev version. Closed loop is disabled.") assertThat(c.getReasons()).contains("Running dev version. Closed loop is disabled.")
@ -104,7 +104,7 @@ class SafetyPluginTest : TestBaseWithProfile() {
@Test @Test
fun setOpenLoopInPreferencesShouldLimitClosedLoop() { fun setOpenLoopInPreferencesShouldLimitClosedLoop() {
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name) `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name)
val c = safetyPlugin.isClosedLoopAllowed(ConstraintObject(true, aapsLogger)) val c = safetyPlugin.isClosedLoopAllowed(ConstraintObject(true, aapsLogger))
assertThat(c.getReasons()).contains("Closed loop mode disabled in preferences") assertThat(c.getReasons()).contains("Closed loop mode disabled in preferences")
assertThat(c.value()).isFalse() assertThat(c.value()).isFalse()
@ -141,7 +141,7 @@ class SafetyPluginTest : TestBaseWithProfile() {
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")
val c = ConstraintObject(Double.MAX_VALUE, aapsLogger) val c = ConstraintObject(Double.MAX_VALUE, aapsLogger)
safetyPlugin.applyBasalConstraints(c, validProfile) safetyPlugin.applyBasalConstraints(c, validProfile)
assertThat(c.value()).isWithin(0.01).of(2.0) assertThat(c.value()).isWithin(0.01).of(2.0)
@ -155,7 +155,7 @@ class SafetyPluginTest : TestBaseWithProfile() {
@Test @Test
fun doNotAllowNegativeBasalRate() { fun doNotAllowNegativeBasalRate() {
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")
val d = ConstraintObject(-0.5, aapsLogger) val d = ConstraintObject(-0.5, aapsLogger)
safetyPlugin.applyBasalConstraints(d, validProfile) safetyPlugin.applyBasalConstraints(d, validProfile)
assertThat(d.value()).isWithin(0.01).of(0.0) assertThat(d.value()).isWithin(0.01).of(0.0)
@ -170,7 +170,7 @@ class SafetyPluginTest : TestBaseWithProfile() {
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")
val i = ConstraintObject(Int.MAX_VALUE, aapsLogger) val i = ConstraintObject(Int.MAX_VALUE, aapsLogger)
safetyPlugin.applyBasalPercentConstraints(i, validProfile) safetyPlugin.applyBasalPercentConstraints(i, validProfile)
assertThat(i.value()).isEqualTo(200) assertThat(i.value()).isEqualTo(200)
@ -193,7 +193,7 @@ Safety: Limiting max basal rate to 500.00 U/h because of pump limit
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true) openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
val i = ConstraintObject(Double.MAX_VALUE, aapsLogger) val i = ConstraintObject(Double.MAX_VALUE, aapsLogger)
openAPSSMBPlugin.applyBasalConstraints(i, validProfile) openAPSSMBPlugin.applyBasalConstraints(i, validProfile)
@ -210,7 +210,7 @@ Safety: Limiting max basal rate to 500.00 U/h because of pump limit
@Test @Test
fun doNotAllowNegativePercentBasalRate() { fun doNotAllowNegativePercentBasalRate() {
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")
val i = ConstraintObject(-22, aapsLogger) val i = ConstraintObject(-22, aapsLogger)
safetyPlugin.applyBasalPercentConstraints(i, validProfile) safetyPlugin.applyBasalPercentConstraints(i, validProfile)
assertThat(i.value()).isEqualTo(0) assertThat(i.value()).isEqualTo(0)
@ -226,8 +226,8 @@ Safety: Limiting max basal rate to 500.00 U/h because of pump limit
@Test @Test
fun bolusAmountShouldBeLimited() { fun bolusAmountShouldBeLimited() {
`when`(sp.getDouble(info.nightscout.core.utils.R.string.key_treatmentssafety_maxbolus, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_treatmentssafety_maxbolus, 3.0)).thenReturn(3.0)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")
val d = safetyPlugin.applyBolusConstraints(ConstraintObject(Double.MAX_VALUE, aapsLogger)) val d = safetyPlugin.applyBolusConstraints(ConstraintObject(Double.MAX_VALUE, aapsLogger))
assertThat(d.value()).isWithin(0.01).of(3.0) assertThat(d.value()).isWithin(0.01).of(3.0)
assertThat(d.getReasons()).isEqualTo( assertThat(d.getReasons()).isEqualTo(
@ -241,8 +241,8 @@ Safety: Limiting max basal rate to 500.00 U/h because of pump limit
@Test @Test
fun doNotAllowNegativeBolusAmount() { fun doNotAllowNegativeBolusAmount() {
`when`(sp.getDouble(info.nightscout.core.utils.R.string.key_treatmentssafety_maxbolus, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.core.utils.R.string.key_treatmentssafety_maxbolus, 3.0)).thenReturn(3.0)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("child") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("child")
val d = safetyPlugin.applyBolusConstraints(ConstraintObject(-22.0, aapsLogger)) val d = safetyPlugin.applyBolusConstraints(ConstraintObject(-22.0, aapsLogger))
assertThat(d.value()).isWithin(0.01).of(0.0) assertThat(d.value()).isWithin(0.01).of(0.0)
assertThat(d.getReasons()).isEqualTo("Safety: Limiting bolus to 0.0 U because of it must be positive value") assertThat(d.getReasons()).isEqualTo("Safety: Limiting bolus to 0.0 U because of it must be positive value")
@ -252,7 +252,7 @@ Safety: Limiting max basal rate to 500.00 U/h because of pump limit
@Test @Test
fun carbsAmountShouldBeLimited() { fun carbsAmountShouldBeLimited() {
// No limit by default // No limit by default
`when`(sp.getInt(info.nightscout.core.utils.R.string.key_treatmentssafety_maxcarbs, 48)).thenReturn(48) `when`(sp.getInt(app.aaps.core.utils.R.string.key_treatmentssafety_maxcarbs, 48)).thenReturn(48)
// Negative carbs not allowed // Negative carbs not allowed
var i: Constraint<Int> = ConstraintObject(-22, aapsLogger) var i: Constraint<Int> = ConstraintObject(-22, aapsLogger)
@ -272,10 +272,10 @@ Safety: Limiting max basal rate to 500.00 U/h because of pump limit
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true) openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
//`when`(openAPSSMBPlugin.isEnabled()).thenReturn(true) //`when`(openAPSSMBPlugin.isEnabled()).thenReturn(true)
//`when`(openAPSAMAPlugin.isEnabled()).thenReturn(false) //`when`(openAPSAMAPlugin.isEnabled()).thenReturn(false)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.LGS.name) `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.LGS.name)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5)
`when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapssmb_max_iob, 3.0)).thenReturn(3.0) `when`(sp.getDouble(app.aaps.plugins.aps.R.string.key_openapssmb_max_iob, 3.0)).thenReturn(3.0)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_age, "")).thenReturn("teenage") `when`(sp.getString(app.aaps.core.utils.R.string.key_age, "")).thenReturn("teenage")
// Apply all limits // Apply all limits
var d: Constraint<Double> = ConstraintObject(Double.MAX_VALUE, aapsLogger) var d: Constraint<Double> = ConstraintObject(Double.MAX_VALUE, aapsLogger)

View file

@ -36,9 +36,9 @@ class InsulinOrefFreePeakPlugin @Inject constructor(
override val friendlyName get(): String = rh.gs(R.string.free_peak_oref) override val friendlyName get(): String = rh.gs(R.string.free_peak_oref)
override fun configuration(): JSONObject = JSONObject().putInt(info.nightscout.core.utils.R.string.key_insulin_oref_peak, sp, rh) override fun configuration(): JSONObject = JSONObject().putInt(app.aaps.core.utils.R.string.key_insulin_oref_peak, sp, rh)
override fun applyConfiguration(configuration: JSONObject) { override fun applyConfiguration(configuration: JSONObject) {
configuration.storeInt(info.nightscout.core.utils.R.string.key_insulin_oref_peak, sp, rh) configuration.storeInt(app.aaps.core.utils.R.string.key_insulin_oref_peak, sp, rh)
} }
override fun commentStandardText(): String { override fun commentStandardText(): String {
@ -46,7 +46,7 @@ class InsulinOrefFreePeakPlugin @Inject constructor(
} }
override val peak: Int override val peak: Int
get() = sp.getInt(info.nightscout.core.utils.R.string.key_insulin_oref_peak, DEFAULT_PEAK) get() = sp.getInt(app.aaps.core.utils.R.string.key_insulin_oref_peak, DEFAULT_PEAK)
companion object { companion object {

View file

@ -45,7 +45,7 @@ class InsulinOrefFreePeakPluginTest : TestBase() {
@Test @Test
fun `simple peak test`() { fun `simple peak test`() {
`when`(sp.getInt(eq(info.nightscout.core.utils.R.string.key_insulin_oref_peak), anyInt())).thenReturn(90) `when`(sp.getInt(eq(app.aaps.core.utils.R.string.key_insulin_oref_peak), anyInt())).thenReturn(90)
assertThat(sut.peak).isEqualTo(90) assertThat(sut.peak).isEqualTo(90)
} }
@ -56,7 +56,7 @@ class InsulinOrefFreePeakPluginTest : TestBase() {
@Test @Test
fun commentStandardTextTest() { fun commentStandardTextTest() {
`when`(sp.getInt(eq(info.nightscout.core.utils.R.string.key_insulin_oref_peak), anyInt())).thenReturn(90) `when`(sp.getInt(eq(app.aaps.core.utils.R.string.key_insulin_oref_peak), anyInt())).thenReturn(90)
`when`(rh.gs(eq(R.string.insulin_peak_time))).thenReturn("Peak Time [min]") `when`(rh.gs(eq(R.string.insulin_peak_time))).thenReturn("Peak Time [min]")
assertThat(sut.commentStandardText()).isEqualTo("Peak Time [min]: 90") assertThat(sut.commentStandardText()).isEqualTo("Peak Time [min]: 90")
} }

View file

@ -183,7 +183,7 @@ class ActionsFragment : DaggerFragment() {
uiInteraction.runCareDialog(childFragmentManager, UiInteraction.EventType.ANNOUNCEMENT, app.aaps.core.ui.R.string.careportal_announcement) uiInteraction.runCareDialog(childFragmentManager, UiInteraction.EventType.ANNOUNCEMENT, app.aaps.core.ui.R.string.careportal_announcement)
} }
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectiveuseactions, true) sp.putBoolean(app.aaps.core.utils.R.string.key_objectiveuseactions, true)
} }
@Synchronized @Synchronized

View file

@ -208,9 +208,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
binding.graphsLayout.bgGraph.setOnLongClickListener { binding.graphsLayout.bgGraph.setOnLongClickListener {
overviewData.rangeToDisplay += 6 overviewData.rangeToDisplay += 6
overviewData.rangeToDisplay = if (overviewData.rangeToDisplay > 24) 6 else overviewData.rangeToDisplay overviewData.rangeToDisplay = if (overviewData.rangeToDisplay > 24) 6 else overviewData.rangeToDisplay
sp.putInt(info.nightscout.core.utils.R.string.key_rangetodisplay, overviewData.rangeToDisplay) sp.putInt(app.aaps.core.utils.R.string.key_rangetodisplay, overviewData.rangeToDisplay)
rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.utils.R.string.key_rangetodisplay))) rxBus.send(EventPreferenceChange(rh.gs(app.aaps.core.utils.R.string.key_rangetodisplay)))
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectiveusescale, true) sp.putBoolean(app.aaps.core.utils.R.string.key_objectiveusescale, true)
false false
} }
prepareGraphsIfNeeded(overviewMenus.setting.size) prepareGraphsIfNeeded(overviewMenus.setting.size)
@ -272,9 +272,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ .subscribe({
overviewData.rangeToDisplay = it.hours overviewData.rangeToDisplay = it.hours
sp.putInt(info.nightscout.core.utils.R.string.key_rangetodisplay, it.hours) sp.putInt(app.aaps.core.utils.R.string.key_rangetodisplay, it.hours)
rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.utils.R.string.key_rangetodisplay))) rxBus.send(EventPreferenceChange(rh.gs(app.aaps.core.utils.R.string.key_rangetodisplay)))
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectiveusescale, true) sp.putBoolean(app.aaps.core.utils.R.string.key_objectiveusescale, true)
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
disposable += rxBus disposable += rxBus
.toObservable(EventBucketedDataCreated::class.java) .toObservable(EventBucketedDataCreated::class.java)
@ -1088,7 +1088,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
private fun updateSensitivity() { private fun updateSensitivity() {
_binding ?: return _binding ?: return
val lastAutosensData = overviewData.lastAutosensData(iobCobCalculator) val lastAutosensData = overviewData.lastAutosensData(iobCobCalculator)
if (config.NSCLIENT && sp.getBoolean(info.nightscout.core.utils.R.string.key_used_autosens_on_main_phone, false) || if (config.NSCLIENT && sp.getBoolean(app.aaps.core.utils.R.string.key_used_autosens_on_main_phone, false) ||
!config.NSCLIENT && constraintChecker.isAutosensModeEnabled().value() !config.NSCLIENT && constraintChecker.isAutosensModeEnabled().value()
) { ) {
binding.infoLayout.sensitivityIcon.setImageResource(app.aaps.core.main.R.drawable.ic_swap_vert_black_48dp_green) binding.infoLayout.sensitivityIcon.setImageResource(app.aaps.core.main.R.drawable.ic_swap_vert_black_48dp_green)

View file

@ -157,7 +157,7 @@ class OverviewPlugin @Inject constructor(
} }
} }
if (!config.isEngineeringMode()) if (!config.isEngineeringMode())
(preferenceFragment.findPreference(rh.gs(info.nightscout.core.utils.R.string.key_reset_boluswizard_percentage_time)) as ValidatingEditTextPreference?)?.let { (preferenceFragment.findPreference(rh.gs(app.aaps.core.utils.R.string.key_reset_boluswizard_percentage_time)) as ValidatingEditTextPreference?)?.let {
it.isVisible = false it.isVisible = false
it.isEnabled = false it.isEnabled = false
} }
@ -165,64 +165,64 @@ class OverviewPlugin @Inject constructor(
override fun configuration(): JSONObject = override fun configuration(): JSONObject =
JSONObject() JSONObject()
.putString(info.nightscout.core.utils.R.string.key_units, sp, rh) .putString(app.aaps.core.utils.R.string.key_units, sp, rh)
.putString(info.nightscout.core.utils.R.string.key_quickwizard, sp, rh) .putString(app.aaps.core.utils.R.string.key_quickwizard, sp, rh)
.putInt(info.nightscout.core.utils.R.string.key_eatingsoon_duration, sp, rh) .putInt(app.aaps.core.utils.R.string.key_eatingsoon_duration, sp, rh)
.putDouble(info.nightscout.core.utils.R.string.key_eatingsoon_target, sp, rh) .putDouble(app.aaps.core.utils.R.string.key_eatingsoon_target, sp, rh)
.putInt(info.nightscout.core.utils.R.string.key_activity_duration, sp, rh) .putInt(app.aaps.core.utils.R.string.key_activity_duration, sp, rh)
.putDouble(info.nightscout.core.utils.R.string.key_activity_target, sp, rh) .putDouble(app.aaps.core.utils.R.string.key_activity_target, sp, rh)
.putInt(info.nightscout.core.utils.R.string.key_hypo_duration, sp, rh) .putInt(app.aaps.core.utils.R.string.key_hypo_duration, sp, rh)
.putDouble(info.nightscout.core.utils.R.string.key_hypo_target, sp, rh) .putDouble(app.aaps.core.utils.R.string.key_hypo_target, sp, rh)
.putDouble(info.nightscout.core.utils.R.string.key_low_mark, sp, rh) .putDouble(app.aaps.core.utils.R.string.key_low_mark, sp, rh)
.putDouble(info.nightscout.core.utils.R.string.key_high_mark, sp, rh) .putDouble(app.aaps.core.utils.R.string.key_high_mark, sp, rh)
.putDouble(info.nightscout.core.utils.R.string.key_statuslights_cage_warning, sp, rh) .putDouble(app.aaps.core.utils.R.string.key_statuslights_cage_warning, sp, rh)
.putDouble(info.nightscout.core.utils.R.string.key_statuslights_cage_critical, sp, rh) .putDouble(app.aaps.core.utils.R.string.key_statuslights_cage_critical, sp, rh)
.putDouble(info.nightscout.core.utils.R.string.key_statuslights_iage_warning, sp, rh) .putDouble(app.aaps.core.utils.R.string.key_statuslights_iage_warning, sp, rh)
.putDouble(info.nightscout.core.utils.R.string.key_statuslights_iage_critical, sp, rh) .putDouble(app.aaps.core.utils.R.string.key_statuslights_iage_critical, sp, rh)
.putDouble(info.nightscout.core.utils.R.string.key_statuslights_sage_warning, sp, rh) .putDouble(app.aaps.core.utils.R.string.key_statuslights_sage_warning, sp, rh)
.putDouble(info.nightscout.core.utils.R.string.key_statuslights_sage_critical, sp, rh) .putDouble(app.aaps.core.utils.R.string.key_statuslights_sage_critical, sp, rh)
.putDouble(R.string.key_statuslights_sbat_warning, sp, rh) .putDouble(R.string.key_statuslights_sbat_warning, sp, rh)
.putDouble(R.string.key_statuslights_sbat_critical, sp, rh) .putDouble(R.string.key_statuslights_sbat_critical, sp, rh)
.putDouble(info.nightscout.core.utils.R.string.key_statuslights_bage_warning, sp, rh) .putDouble(app.aaps.core.utils.R.string.key_statuslights_bage_warning, sp, rh)
.putDouble(info.nightscout.core.utils.R.string.key_statuslights_bage_critical, sp, rh) .putDouble(app.aaps.core.utils.R.string.key_statuslights_bage_critical, sp, rh)
.putDouble(R.string.key_statuslights_res_warning, sp, rh) .putDouble(R.string.key_statuslights_res_warning, sp, rh)
.putDouble(R.string.key_statuslights_res_critical, sp, rh) .putDouble(R.string.key_statuslights_res_critical, sp, rh)
.putDouble(R.string.key_statuslights_bat_warning, sp, rh) .putDouble(R.string.key_statuslights_bat_warning, sp, rh)
.putDouble(R.string.key_statuslights_bat_critical, sp, rh) .putDouble(R.string.key_statuslights_bat_critical, sp, rh)
.putInt(info.nightscout.core.utils.R.string.key_boluswizard_percentage, sp, rh) .putInt(app.aaps.core.utils.R.string.key_boluswizard_percentage, sp, rh)
.put(rh.gs(info.nightscout.core.utils.R.string.key_used_autosens_on_main_phone), constraintsChecker.isAutosensModeEnabled().value()) // can be disabled by activated DynISF .put(rh.gs(app.aaps.core.utils.R.string.key_used_autosens_on_main_phone), constraintsChecker.isAutosensModeEnabled().value()) // can be disabled by activated DynISF
override fun applyConfiguration(configuration: JSONObject) { override fun applyConfiguration(configuration: JSONObject) {
val previousUnits = sp.getString(info.nightscout.core.utils.R.string.key_units, "random") val previousUnits = sp.getString(app.aaps.core.utils.R.string.key_units, "random")
configuration configuration
.storeString(info.nightscout.core.utils.R.string.key_units, sp, rh) .storeString(app.aaps.core.utils.R.string.key_units, sp, rh)
.storeString(info.nightscout.core.utils.R.string.key_quickwizard, sp, rh) .storeString(app.aaps.core.utils.R.string.key_quickwizard, sp, rh)
.storeInt(info.nightscout.core.utils.R.string.key_eatingsoon_duration, sp, rh) .storeInt(app.aaps.core.utils.R.string.key_eatingsoon_duration, sp, rh)
.storeDouble(info.nightscout.core.utils.R.string.key_eatingsoon_target, sp, rh) .storeDouble(app.aaps.core.utils.R.string.key_eatingsoon_target, sp, rh)
.storeInt(info.nightscout.core.utils.R.string.key_activity_duration, sp, rh) .storeInt(app.aaps.core.utils.R.string.key_activity_duration, sp, rh)
.storeDouble(info.nightscout.core.utils.R.string.key_activity_target, sp, rh) .storeDouble(app.aaps.core.utils.R.string.key_activity_target, sp, rh)
.storeInt(info.nightscout.core.utils.R.string.key_hypo_duration, sp, rh) .storeInt(app.aaps.core.utils.R.string.key_hypo_duration, sp, rh)
.storeDouble(info.nightscout.core.utils.R.string.key_hypo_target, sp, rh) .storeDouble(app.aaps.core.utils.R.string.key_hypo_target, sp, rh)
.storeDouble(info.nightscout.core.utils.R.string.key_low_mark, sp, rh) .storeDouble(app.aaps.core.utils.R.string.key_low_mark, sp, rh)
.storeDouble(info.nightscout.core.utils.R.string.key_high_mark, sp, rh) .storeDouble(app.aaps.core.utils.R.string.key_high_mark, sp, rh)
.storeDouble(info.nightscout.core.utils.R.string.key_statuslights_cage_warning, sp, rh) .storeDouble(app.aaps.core.utils.R.string.key_statuslights_cage_warning, sp, rh)
.storeDouble(info.nightscout.core.utils.R.string.key_statuslights_cage_critical, sp, rh) .storeDouble(app.aaps.core.utils.R.string.key_statuslights_cage_critical, sp, rh)
.storeDouble(info.nightscout.core.utils.R.string.key_statuslights_iage_warning, sp, rh) .storeDouble(app.aaps.core.utils.R.string.key_statuslights_iage_warning, sp, rh)
.storeDouble(info.nightscout.core.utils.R.string.key_statuslights_iage_critical, sp, rh) .storeDouble(app.aaps.core.utils.R.string.key_statuslights_iage_critical, sp, rh)
.storeDouble(info.nightscout.core.utils.R.string.key_statuslights_sage_warning, sp, rh) .storeDouble(app.aaps.core.utils.R.string.key_statuslights_sage_warning, sp, rh)
.storeDouble(info.nightscout.core.utils.R.string.key_statuslights_sage_critical, sp, rh) .storeDouble(app.aaps.core.utils.R.string.key_statuslights_sage_critical, sp, rh)
.storeDouble(R.string.key_statuslights_sbat_warning, sp, rh) .storeDouble(R.string.key_statuslights_sbat_warning, sp, rh)
.storeDouble(R.string.key_statuslights_sbat_critical, sp, rh) .storeDouble(R.string.key_statuslights_sbat_critical, sp, rh)
.storeDouble(info.nightscout.core.utils.R.string.key_statuslights_bage_warning, sp, rh) .storeDouble(app.aaps.core.utils.R.string.key_statuslights_bage_warning, sp, rh)
.storeDouble(info.nightscout.core.utils.R.string.key_statuslights_bage_critical, sp, rh) .storeDouble(app.aaps.core.utils.R.string.key_statuslights_bage_critical, sp, rh)
.storeDouble(R.string.key_statuslights_res_warning, sp, rh) .storeDouble(R.string.key_statuslights_res_warning, sp, rh)
.storeDouble(R.string.key_statuslights_res_critical, sp, rh) .storeDouble(R.string.key_statuslights_res_critical, sp, rh)
.storeDouble(R.string.key_statuslights_bat_warning, sp, rh) .storeDouble(R.string.key_statuslights_bat_warning, sp, rh)
.storeDouble(R.string.key_statuslights_bat_critical, sp, rh) .storeDouble(R.string.key_statuslights_bat_critical, sp, rh)
.storeInt(info.nightscout.core.utils.R.string.key_boluswizard_percentage, sp, rh) .storeInt(app.aaps.core.utils.R.string.key_boluswizard_percentage, sp, rh)
.storeBoolean(info.nightscout.core.utils.R.string.key_used_autosens_on_main_phone, sp, rh) .storeBoolean(app.aaps.core.utils.R.string.key_used_autosens_on_main_phone, sp, rh)
val newUnits = sp.getString(info.nightscout.core.utils.R.string.key_units, "new") val newUnits = sp.getString(app.aaps.core.utils.R.string.key_units, "new")
if (previousUnits != newUnits) { if (previousUnits != newUnits) {
overviewData.reset() overviewData.reset()
rxBus.send(EventNewHistoryData(0L, reloadBgData = true)) rxBus.send(EventNewHistoryData(0L, reloadBgData = true))

View file

@ -62,9 +62,9 @@ class NotificationWithAction(
activePlugin.activeNsClient?.handleClearAlarm(nsAlarm, 60 * 60 * 1000L) activePlugin.activeNsClient?.handleClearAlarm(nsAlarm, 60 * 60 * 1000L)
// Adding current time to snooze if we got staleData // Adding current time to snooze if we got staleData
aapsLogger.debug(LTag.NOTIFICATION, "Notification text is: $text") aapsLogger.debug(LTag.NOTIFICATION, "Notification text is: $text")
val msToSnooze = sp.getInt(info.nightscout.core.utils.R.string.key_ns_alarm_stale_data_value, 15) * 60 * 1000L val msToSnooze = sp.getInt(app.aaps.core.utils.R.string.key_ns_alarm_stale_data_value, 15) * 60 * 1000L
aapsLogger.debug(LTag.NOTIFICATION, "snooze nsalarm_staledatavalue in minutes is ${T.msecs(msToSnooze).mins()} currentTimeMillis is: ${System.currentTimeMillis()}") aapsLogger.debug(LTag.NOTIFICATION, "snooze nsalarm_staledatavalue in minutes is ${T.msecs(msToSnooze).mins()} currentTimeMillis is: ${System.currentTimeMillis()}")
sp.putLong(rh.gs(info.nightscout.core.utils.R.string.key_snoozed_to) + nsAlarm.level(), System.currentTimeMillis() + msToSnooze) sp.putLong(rh.gs(app.aaps.core.utils.R.string.key_snoozed_to) + nsAlarm.level(), System.currentTimeMillis() + msToSnooze)
} }
} }

View file

@ -56,34 +56,34 @@ class StatusLightHandler @Inject constructor(
handleAge( handleAge(
cannulaAge, cannulaAge,
TherapyEvent.Type.CANNULA_CHANGE, TherapyEvent.Type.CANNULA_CHANGE,
info.nightscout.core.utils.R.string.key_statuslights_cage_warning, app.aaps.core.utils.R.string.key_statuslights_cage_warning,
48.0, 48.0,
info.nightscout.core.utils.R.string.key_statuslights_cage_critical, app.aaps.core.utils.R.string.key_statuslights_cage_critical,
72.0 72.0
) )
handleAge( handleAge(
insulinAge, insulinAge,
TherapyEvent.Type.INSULIN_CHANGE, TherapyEvent.Type.INSULIN_CHANGE,
info.nightscout.core.utils.R.string.key_statuslights_iage_warning, app.aaps.core.utils.R.string.key_statuslights_iage_warning,
72.0, 72.0,
info.nightscout.core.utils.R.string.key_statuslights_iage_critical, app.aaps.core.utils.R.string.key_statuslights_iage_critical,
144.0 144.0
) )
handleAge( handleAge(
sensorAge, sensorAge,
TherapyEvent.Type.SENSOR_CHANGE, TherapyEvent.Type.SENSOR_CHANGE,
info.nightscout.core.utils.R.string.key_statuslights_sage_warning, app.aaps.core.utils.R.string.key_statuslights_sage_warning,
216.0, 216.0,
info.nightscout.core.utils.R.string.key_statuslights_sage_critical, app.aaps.core.utils.R.string.key_statuslights_sage_critical,
240.0 240.0
) )
if (pump.pumpDescription.isBatteryReplaceable || pump.isBatteryChangeLoggingEnabled()) { if (pump.pumpDescription.isBatteryReplaceable || pump.isBatteryChangeLoggingEnabled()) {
handleAge( handleAge(
batteryAge, batteryAge,
TherapyEvent.Type.PUMP_BATTERY_CHANGE, TherapyEvent.Type.PUMP_BATTERY_CHANGE,
info.nightscout.core.utils.R.string.key_statuslights_bage_warning, app.aaps.core.utils.R.string.key_statuslights_bage_warning,
216.0, 216.0,
info.nightscout.core.utils.R.string.key_statuslights_bage_critical, app.aaps.core.utils.R.string.key_statuslights_bage_critical,
240.0 240.0
) )
} }

View file

@ -512,7 +512,7 @@ class SmsCommunicatorPlugin @Inject constructor(
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(pumpCommand = false) { messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(pumpCommand = false) {
override fun run() { override fun run() {
uel.log(Action.LGS_LOOP_MODE, Sources.SMS) uel.log(Action.LGS_LOOP_MODE, Sources.SMS)
sp.putString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.LGS.name) sp.putString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.LGS.name)
rxBus.send(EventPreferenceChange(rh.gs(app.aaps.core.ui.R.string.lowglucosesuspend))) rxBus.send(EventPreferenceChange(rh.gs(app.aaps.core.ui.R.string.lowglucosesuspend)))
val replyText = rh.gs(R.string.smscommunicator_current_loop_mode, getApsModeText()) val replyText = rh.gs(R.string.smscommunicator_current_loop_mode, getApsModeText())
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
@ -527,7 +527,7 @@ class SmsCommunicatorPlugin @Inject constructor(
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(pumpCommand = false) { messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(pumpCommand = false) {
override fun run() { override fun run() {
uel.log(Action.CLOSED_LOOP_MODE, Sources.SMS) uel.log(Action.CLOSED_LOOP_MODE, Sources.SMS)
sp.putString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.CLOSED.name) sp.putString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.CLOSED.name)
rxBus.send(EventPreferenceChange(rh.gs(app.aaps.core.ui.R.string.closedloop))) rxBus.send(EventPreferenceChange(rh.gs(app.aaps.core.ui.R.string.closedloop)))
val replyText = rh.gs(R.string.smscommunicator_current_loop_mode, getApsModeText()) val replyText = rh.gs(R.string.smscommunicator_current_loop_mode, getApsModeText())
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
@ -947,13 +947,13 @@ class SmsCommunicatorPlugin @Inject constructor(
lastRemoteBolusTime = dateUtil.now() lastRemoteBolusTime = dateUtil.now()
if (isMeal) { if (isMeal) {
profileFunction.getProfile()?.let { currentProfile -> profileFunction.getProfile()?.let { currentProfile ->
var eatingSoonTTDuration = sp.getInt(info.nightscout.core.utils.R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration) var eatingSoonTTDuration = sp.getInt(app.aaps.core.utils.R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration)
eatingSoonTTDuration = eatingSoonTTDuration =
if (eatingSoonTTDuration > 0) eatingSoonTTDuration if (eatingSoonTTDuration > 0) eatingSoonTTDuration
else Constants.defaultEatingSoonTTDuration else Constants.defaultEatingSoonTTDuration
var eatingSoonTT = var eatingSoonTT =
sp.getDouble( sp.getDouble(
info.nightscout.core.utils.R.string.key_eatingsoon_target, app.aaps.core.utils.R.string.key_eatingsoon_target,
if (currentProfile.units == GlucoseUnit.MMOL) Constants.defaultEatingSoonTTmmol else Constants.defaultEatingSoonTTmgdl if (currentProfile.units == GlucoseUnit.MMOL) Constants.defaultEatingSoonTTmmol else Constants.defaultEatingSoonTTmgdl
) )
eatingSoonTT = eatingSoonTT =
@ -1088,27 +1088,27 @@ class SmsCommunicatorPlugin @Inject constructor(
var reason = TemporaryTarget.Reason.EATING_SOON var reason = TemporaryTarget.Reason.EATING_SOON
when { when {
isMeal -> { isMeal -> {
keyDuration = info.nightscout.core.utils.R.string.key_eatingsoon_duration keyDuration = app.aaps.core.utils.R.string.key_eatingsoon_duration
defaultTargetDuration = Constants.defaultEatingSoonTTDuration defaultTargetDuration = Constants.defaultEatingSoonTTDuration
keyTarget = info.nightscout.core.utils.R.string.key_eatingsoon_target keyTarget = app.aaps.core.utils.R.string.key_eatingsoon_target
defaultTargetMMOL = Constants.defaultEatingSoonTTmmol defaultTargetMMOL = Constants.defaultEatingSoonTTmmol
defaultTargetMGDL = Constants.defaultEatingSoonTTmgdl defaultTargetMGDL = Constants.defaultEatingSoonTTmgdl
reason = TemporaryTarget.Reason.EATING_SOON reason = TemporaryTarget.Reason.EATING_SOON
} }
isActivity -> { isActivity -> {
keyDuration = info.nightscout.core.utils.R.string.key_activity_duration keyDuration = app.aaps.core.utils.R.string.key_activity_duration
defaultTargetDuration = Constants.defaultActivityTTDuration defaultTargetDuration = Constants.defaultActivityTTDuration
keyTarget = info.nightscout.core.utils.R.string.key_activity_target keyTarget = app.aaps.core.utils.R.string.key_activity_target
defaultTargetMMOL = Constants.defaultActivityTTmmol defaultTargetMMOL = Constants.defaultActivityTTmmol
defaultTargetMGDL = Constants.defaultActivityTTmgdl defaultTargetMGDL = Constants.defaultActivityTTmgdl
reason = TemporaryTarget.Reason.ACTIVITY reason = TemporaryTarget.Reason.ACTIVITY
} }
isHypo -> { isHypo -> {
keyDuration = info.nightscout.core.utils.R.string.key_hypo_duration keyDuration = app.aaps.core.utils.R.string.key_hypo_duration
defaultTargetDuration = Constants.defaultHypoTTDuration defaultTargetDuration = Constants.defaultHypoTTDuration
keyTarget = info.nightscout.core.utils.R.string.key_hypo_target keyTarget = app.aaps.core.utils.R.string.key_hypo_target
defaultTargetMMOL = Constants.defaultHypoTTmmol defaultTargetMMOL = Constants.defaultHypoTTmmol
defaultTargetMGDL = Constants.defaultHypoTTmgdl defaultTargetMGDL = Constants.defaultHypoTTmgdl
reason = TemporaryTarget.Reason.HYPOGLYCEMIA reason = TemporaryTarget.Reason.HYPOGLYCEMIA
@ -1291,7 +1291,7 @@ class SmsCommunicatorPlugin @Inject constructor(
} }
private fun getApsModeText(): String = private fun getApsModeText(): String =
when (ApsMode.fromString(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name))) { when (ApsMode.fromString(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name))) {
ApsMode.OPEN -> rh.gs(app.aaps.core.ui.R.string.openloop) ApsMode.OPEN -> rh.gs(app.aaps.core.ui.R.string.openloop)
ApsMode.CLOSED -> rh.gs(app.aaps.core.ui.R.string.closedloop) ApsMode.CLOSED -> rh.gs(app.aaps.core.ui.R.string.closedloop)
ApsMode.LGS -> rh.gs(app.aaps.core.ui.R.string.lowglucosesuspend) ApsMode.LGS -> rh.gs(app.aaps.core.ui.R.string.lowglucosesuspend)

View file

@ -37,7 +37,7 @@ class OneTimePassword @Inject constructor(
*/ */
fun name(): String { fun name(): String {
val defaultUserName = rh.gs(app.aaps.core.ui.R.string.patient_name_default) val defaultUserName = rh.gs(app.aaps.core.ui.R.string.patient_name_default)
var userName = sp.getString(info.nightscout.core.utils.R.string.key_patient_name, defaultUserName).replace(":", "").trim() var userName = sp.getString(app.aaps.core.utils.R.string.key_patient_name, defaultUserName).replace(":", "").trim()
if (userName.isEmpty()) if (userName.isEmpty())
userName = defaultUserName userName = defaultUserName
return userName return userName

View file

@ -40,7 +40,7 @@ class ThemeSwitcherPlugin @Inject constructor(
override fun onStart() { override fun onStart() {
compositeDisposable.add(rxBus.toObservable(EventPreferenceChange::class.java).subscribe { compositeDisposable.add(rxBus.toObservable(EventPreferenceChange::class.java).subscribe {
if (it.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_use_dark_mode))) { if (it.isChanged(rh.gs(app.aaps.core.utils.R.string.key_use_dark_mode))) {
setThemeMode() setThemeMode()
rxBus.send(EventThemeSwitch()) rxBus.send(EventThemeSwitch())
} }
@ -49,7 +49,7 @@ class ThemeSwitcherPlugin @Inject constructor(
fun setThemeMode() { fun setThemeMode() {
val mode = try { val mode = try {
when (sp.getString(info.nightscout.core.utils.R.string.key_use_dark_mode, "dark")) { when (sp.getString(app.aaps.core.utils.R.string.key_use_dark_mode, "dark")) {
sp.getString(R.string.value_dark_theme, "dark") -> MODE_NIGHT_YES sp.getString(R.string.value_dark_theme, "dark") -> MODE_NIGHT_YES
sp.getString(R.string.value_light_theme, "light") -> MODE_NIGHT_NO sp.getString(R.string.value_light_theme, "light") -> MODE_NIGHT_NO
else -> MODE_NIGHT_FOLLOW_SYSTEM else -> MODE_NIGHT_FOLLOW_SYSTEM

View file

@ -112,11 +112,11 @@ class WearPlugin @Inject constructor(
fun checkCustomWatchfacePreferences() { fun checkCustomWatchfacePreferences() {
savedCustomWatchface?.let { cwf -> savedCustomWatchface?.let { cwf ->
val cwf_authorization = sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_custom_watchface_autorization, false) val cwf_authorization = sp.getBoolean(app.aaps.core.utils.R.string.key_wear_custom_watchface_autorization, false)
if (cwf_authorization != cwf.metadata[CwfMetadataKey.CWF_AUTHORIZATION]?.toBooleanStrictOrNull()) { if (cwf_authorization != cwf.metadata[CwfMetadataKey.CWF_AUTHORIZATION]?.toBooleanStrictOrNull()) {
// resend new customWatchface to Watch with updated authorization for preferences update // resend new customWatchface to Watch with updated authorization for preferences update
val newCwf = cwf.copy() val newCwf = cwf.copy()
newCwf.metadata[CwfMetadataKey.CWF_AUTHORIZATION] = sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_custom_watchface_autorization, false).toString() newCwf.metadata[CwfMetadataKey.CWF_AUTHORIZATION] = sp.getBoolean(app.aaps.core.utils.R.string.key_wear_custom_watchface_autorization, false).toString()
rxBus.send(EventMobileDataToWear(EventData.ActionSetCustomWatchface(newCwf))) rxBus.send(EventMobileDataToWear(EventData.ActionSetCustomWatchface(newCwf)))
} }
} }

View file

@ -85,7 +85,7 @@ class CwfInfosActivity : TranslatedDaggerAppCompatActivity() {
private fun updateGui() { private fun updateGui() {
wearPlugin.savedCustomWatchface?.let { wearPlugin.savedCustomWatchface?.let {
val cwfAuthorization = sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_custom_watchface_autorization, false) val cwfAuthorization = sp.getBoolean(app.aaps.core.utils.R.string.key_wear_custom_watchface_autorization, false)
val metadata = it.metadata val metadata = it.metadata
val drawable = it.resDatas[ResFileMap.CUSTOM_WATCHFACE.fileName]?.toDrawable(resources) val drawable = it.resDatas[ResFileMap.CUSTOM_WATCHFACE.fileName]?.toDrawable(resources)
binding.customWatchface.setImageDrawable(drawable) binding.customWatchface.setImageDrawable(drawable)

View file

@ -417,13 +417,13 @@ class DataHandlerMobile @Inject constructor(
bg = bgReading.valueToUnits(profileFunction.getUnits()), bg = bgReading.valueToUnits(profileFunction.getUnits()),
correction = 0.0, correction = 0.0,
percentageCorrection = percentage, percentageCorrection = percentage,
useBg = sp.getBoolean(info.nightscout.core.utils.R.string.key_wearwizard_bg, true), useBg = sp.getBoolean(app.aaps.core.utils.R.string.key_wearwizard_bg, true),
useCob = sp.getBoolean(info.nightscout.core.utils.R.string.key_wearwizard_cob, true), useCob = sp.getBoolean(app.aaps.core.utils.R.string.key_wearwizard_cob, true),
includeBolusIOB = sp.getBoolean(info.nightscout.core.utils.R.string.key_wearwizard_iob, true), includeBolusIOB = sp.getBoolean(app.aaps.core.utils.R.string.key_wearwizard_iob, true),
includeBasalIOB = sp.getBoolean(info.nightscout.core.utils.R.string.key_wearwizard_iob, true), includeBasalIOB = sp.getBoolean(app.aaps.core.utils.R.string.key_wearwizard_iob, true),
useSuperBolus = false, useSuperBolus = false,
useTT = sp.getBoolean(info.nightscout.core.utils.R.string.key_wearwizard_tt, false), useTT = sp.getBoolean(app.aaps.core.utils.R.string.key_wearwizard_tt, false),
useTrend = sp.getBoolean(info.nightscout.core.utils.R.string.key_wearwizard_trend, false), useTrend = sp.getBoolean(app.aaps.core.utils.R.string.key_wearwizard_trend, false),
useAlarm = false useAlarm = false
) )
val insulinAfterConstraints = bolusWizard.insulinAfterConstraints val insulinAfterConstraints = bolusWizard.insulinAfterConstraints
@ -745,15 +745,15 @@ class DataHandlerMobile @Inject constructor(
EventMobileToWear( EventMobileToWear(
EventData.Preferences( EventData.Preferences(
timeStamp = System.currentTimeMillis(), timeStamp = System.currentTimeMillis(),
wearControl = sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_control, false), wearControl = sp.getBoolean(app.aaps.core.utils.R.string.key_wear_control, false),
unitsMgdl = profileFunction.getUnits() == GlucoseUnit.MGDL, unitsMgdl = profileFunction.getUnits() == GlucoseUnit.MGDL,
bolusPercentage = sp.getInt(info.nightscout.core.utils.R.string.key_boluswizard_percentage, 100), bolusPercentage = sp.getInt(app.aaps.core.utils.R.string.key_boluswizard_percentage, 100),
maxCarbs = sp.getInt(info.nightscout.core.utils.R.string.key_treatmentssafety_maxcarbs, 48), maxCarbs = sp.getInt(app.aaps.core.utils.R.string.key_treatmentssafety_maxcarbs, 48),
maxBolus = sp.getDouble(info.nightscout.core.utils.R.string.key_treatmentssafety_maxbolus, 3.0), maxBolus = sp.getDouble(app.aaps.core.utils.R.string.key_treatmentssafety_maxbolus, 3.0),
insulinButtonIncrement1 = sp.getDouble(app.aaps.core.interfaces.R.string.key_insulin_button_increment_1, Constants.INSULIN_PLUS1_DEFAULT), insulinButtonIncrement1 = sp.getDouble(app.aaps.core.interfaces.R.string.key_insulin_button_increment_1, Constants.INSULIN_PLUS1_DEFAULT),
insulinButtonIncrement2 = sp.getDouble(app.aaps.core.interfaces.R.string.key_insulin_button_increment_2, Constants.INSULIN_PLUS2_DEFAULT), insulinButtonIncrement2 = sp.getDouble(app.aaps.core.interfaces.R.string.key_insulin_button_increment_2, Constants.INSULIN_PLUS2_DEFAULT),
carbsButtonIncrement1 = sp.getInt(info.nightscout.core.utils.R.string.key_carbs_button_increment_1, Constants.CARBS_FAV1_DEFAULT), carbsButtonIncrement1 = sp.getInt(app.aaps.core.utils.R.string.key_carbs_button_increment_1, Constants.CARBS_FAV1_DEFAULT),
carbsButtonIncrement2 = sp.getInt(info.nightscout.core.utils.R.string.key_carbs_button_increment_2, Constants.CARBS_FAV2_DEFAULT) carbsButtonIncrement2 = sp.getInt(app.aaps.core.utils.R.string.key_carbs_button_increment_2, Constants.CARBS_FAV2_DEFAULT)
) )
) )
) )

View file

@ -122,14 +122,14 @@ class IobCobCalculatorPlugin @Inject constructor(
.toObservable(EventPreferenceChange::class.java) .toObservable(EventPreferenceChange::class.java)
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribe({ event -> .subscribe({ event ->
if (event.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_period)) || if (event.isChanged(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_period)) ||
event.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_age)) || event.isChanged(rh.gs(app.aaps.core.utils.R.string.key_age)) ||
event.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_absorption_maxtime)) || event.isChanged(rh.gs(app.aaps.core.utils.R.string.key_absorption_maxtime)) ||
event.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact)) || event.isChanged(rh.gs(app.aaps.core.utils.R.string.key_openapsama_min_5m_carbimpact)) ||
event.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_absorption_cutoff)) || event.isChanged(rh.gs(app.aaps.core.utils.R.string.key_absorption_cutoff)) ||
event.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_max)) || event.isChanged(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_max)) ||
event.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_min)) || event.isChanged(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_min)) ||
event.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_insulin_oref_peak)) event.isChanged(rh.gs(app.aaps.core.utils.R.string.key_insulin_oref_peak))
) { ) {
resetDataAndRunCalculation("onEventPreferenceChange", event) resetDataAndRunCalculation("onEventPreferenceChange", event)
} }
@ -490,7 +490,7 @@ class IobCobCalculatorPlugin @Inject constructor(
val total = IobTotal(toTime) val total = IobTotal(toTime)
val profile = profileFunction.getProfile() ?: return total val profile = profileFunction.getProfile() ?: return total
val dia = profile.dia val dia = profile.dia
val divisor = sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_bolus_snooze_dia_divisor, 2.0) val divisor = sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_bolus_snooze_dia_divisor, 2.0)
assert(divisor > 0) assert(divisor > 0)
val boluses = repository.getBolusesDataFromTime(toTime - range(), true).blockingGet() val boluses = repository.getBolusesDataFromTime(toTime - range(), true).blockingGet()

View file

@ -92,8 +92,8 @@ class AutosensDataObject(injector: HasAndroidInjector) : AutosensData {
// remove carbs older than timeframe // remove carbs older than timeframe
override fun removeOldCarbs(toTime: Long, isAAPSOrWeighted: Boolean) { override fun removeOldCarbs(toTime: Long, isAAPSOrWeighted: Boolean) {
val maxAbsorptionHours: Double = val maxAbsorptionHours: Double =
if (isAAPSOrWeighted) sp.getDouble(info.nightscout.core.utils.R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME) if (isAAPSOrWeighted) sp.getDouble(app.aaps.core.utils.R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME)
else sp.getDouble(info.nightscout.core.utils.R.string.key_absorption_cutoff, Constants.DEFAULT_MAX_ABSORPTION_TIME) else sp.getDouble(app.aaps.core.utils.R.string.key_absorption_cutoff, Constants.DEFAULT_MAX_ABSORPTION_TIME)
var i = 0 var i = 0
while (i < activeCarbsList.size) { while (i < activeCarbsList.size) {
val c = activeCarbsList[i] val c = activeCarbsList[i]

View file

@ -187,7 +187,7 @@ class ProfilePlugin @Inject constructor(
} }
sp.putInt(Constants.LOCAL_PROFILE + "_profiles", numOfProfiles) sp.putInt(Constants.LOCAL_PROFILE + "_profiles", numOfProfiles)
sp.putLong(info.nightscout.core.utils.R.string.key_local_profile_last_change, timestamp) sp.putLong(app.aaps.core.utils.R.string.key_local_profile_last_change, timestamp)
createAndStoreConvertedProfile() createAndStoreConvertedProfile()
isEdited = false isEdited = false
aapsLogger.debug(LTag.PROFILE, "Storing settings: " + rawProfile?.data.toString()) aapsLogger.debug(LTag.PROFILE, "Storing settings: " + rawProfile?.data.toString())
@ -406,7 +406,7 @@ class ProfilePlugin @Inject constructor(
} }
} }
if (numOfProfiles > 0) json.put("defaultProfile", currentProfile()?.name) if (numOfProfiles > 0) json.put("defaultProfile", currentProfile()?.name)
val startDate = sp.getLong(info.nightscout.core.utils.R.string.key_local_profile_last_change, dateUtil.now()) val startDate = sp.getLong(app.aaps.core.utils.R.string.key_local_profile_last_change, dateUtil.now())
json.put("date", startDate) json.put("date", startDate)
json.put("created_at", dateUtil.toISOAsUTC(startDate)) json.put("created_at", dateUtil.toISOAsUTC(startDate))
json.put("startDate", dateUtil.toISOAsUTC(startDate)) json.put("startDate", dateUtil.toISOAsUTC(startDate))

View file

@ -327,7 +327,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
//LOOP STATUS : enabled - APS mode - Closed //LOOP STATUS : enabled - APS mode - Closed
`when`(loop.enabled).thenReturn(true) `when`(loop.enabled).thenReturn(true)
`when`(loop.isSuspended).thenReturn(false) `when`(loop.isSuspended).thenReturn(false)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name) `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "LOOP STATUS") sms = Sms("1234", "LOOP STATUS")
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -336,7 +336,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
assertThat(smsCommunicatorPlugin.messages[1].text).isEqualTo("Loop is enabled - $modeClosed") assertThat(smsCommunicatorPlugin.messages[1].text).isEqualTo("Loop is enabled - $modeClosed")
//LOOP STATUS : enabled - APS mode - Open //LOOP STATUS : enabled - APS mode - Open
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name) `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.OPEN.name)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
assertThat(sms.ignored).isFalse() assertThat(sms.ignored).isFalse()
@ -344,7 +344,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
assertThat(smsCommunicatorPlugin.messages[1].text).isEqualTo("Loop is enabled - $modeOpen") assertThat(smsCommunicatorPlugin.messages[1].text).isEqualTo("Loop is enabled - $modeOpen")
//LOOP STATUS : enabled - APS mode - LGS //LOOP STATUS : enabled - APS mode - LGS
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.LGS.name) `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.LGS.name)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
assertThat(sms.ignored).isFalse() assertThat(sms.ignored).isFalse()
@ -352,7 +352,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
assertThat(smsCommunicatorPlugin.messages[1].text).isEqualTo("Loop is enabled - $modeLgs") assertThat(smsCommunicatorPlugin.messages[1].text).isEqualTo("Loop is enabled - $modeLgs")
//LOOP STATUS : enabled - APS mode - unknown //LOOP STATUS : enabled - APS mode - unknown
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn("some wrong value") `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn("some wrong value")
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
assertThat(sms.ignored).isFalse() assertThat(sms.ignored).isFalse()
@ -504,7 +504,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
var smsCommand = "LOOP CLOSED" var smsCommand = "LOOP CLOSED"
val replyClosed = "In order to switch Loop mode to Closed loop reply with code " val replyClosed = "In order to switch Loop mode to Closed loop reply with code "
`when`(loop.enabled).thenReturn(true) `when`(loop.enabled).thenReturn(true)
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name) `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", smsCommand) sms = Sms("1234", smsCommand)
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -519,7 +519,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
//LOOP LGS //LOOP LGS
smsCommand = "LOOP LGS" smsCommand = "LOOP LGS"
val replyLgs = "In order to switch Loop mode to LGS (Low Glucose Suspend) reply with code " val replyLgs = "In order to switch Loop mode to LGS (Low Glucose Suspend) reply with code "
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.LGS.name) `when`(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.LGS.name)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", smsCommand) sms = Sms("1234", smsCommand)
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)

View file

@ -32,8 +32,8 @@ abstract class AbstractSensitivityPlugin(
return fillResult( return fillResult(
ratio, carbsAbsorbed, pastSensitivity, ratioLimit, sensResult, ratio, carbsAbsorbed, pastSensitivity, ratioLimit, sensResult,
deviationsArraySize, deviationsArraySize,
SafeParse.stringToDouble(sp.getString(info.nightscout.core.utils.R.string.key_openapsama_autosens_min, "0.7")), SafeParse.stringToDouble(sp.getString(app.aaps.core.utils.R.string.key_openapsama_autosens_min, "0.7")),
SafeParse.stringToDouble(sp.getString(info.nightscout.core.utils.R.string.key_openapsama_autosens_max, "1.2")) SafeParse.stringToDouble(sp.getString(app.aaps.core.utils.R.string.key_openapsama_autosens_max, "1.2"))
) )
} }

View file

@ -49,12 +49,12 @@ class SensitivityAAPSPlugin @Inject constructor(
) { ) {
override fun detectSensitivity(ads: AutosensDataStore, fromTime: Long, toTime: Long): AutosensResult { override fun detectSensitivity(ads: AutosensDataStore, fromTime: Long, toTime: Long): AutosensResult {
val age = sp.getString(info.nightscout.core.utils.R.string.key_age, "") val age = sp.getString(app.aaps.core.utils.R.string.key_age, "")
var defaultHours = 24 var defaultHours = 24
if (age == rh.gs(info.nightscout.core.utils.R.string.key_adult)) defaultHours = 24 if (age == rh.gs(app.aaps.core.utils.R.string.key_adult)) defaultHours = 24
if (age == rh.gs(info.nightscout.core.utils.R.string.key_teenage)) defaultHours = 4 if (age == rh.gs(app.aaps.core.utils.R.string.key_teenage)) defaultHours = 4
if (age == rh.gs(info.nightscout.core.utils.R.string.key_child)) defaultHours = 4 if (age == rh.gs(app.aaps.core.utils.R.string.key_child)) defaultHours = 4
val hoursForDetection = sp.getInt(info.nightscout.core.utils.R.string.key_openapsama_autosens_period, defaultHours) val hoursForDetection = sp.getInt(app.aaps.core.utils.R.string.key_openapsama_autosens_period, defaultHours)
val profile = profileFunction.getProfile() val profile = profileFunction.getProfile()
if (profile == null) { if (profile == null) {
aapsLogger.error("No profile") aapsLogger.error("No profile")
@ -139,7 +139,7 @@ class SensitivityAAPSPlugin @Inject constructor(
return output return output
} }
override fun maxAbsorptionHours(): Double = sp.getDouble(info.nightscout.core.utils.R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME) override fun maxAbsorptionHours(): Double = sp.getDouble(app.aaps.core.utils.R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME)
override val isMinCarbsAbsorptionDynamic: Boolean = true override val isMinCarbsAbsorptionDynamic: Boolean = true
override val isOref1: Boolean = false override val isOref1: Boolean = false
@ -149,10 +149,10 @@ class SensitivityAAPSPlugin @Inject constructor(
override fun configuration(): JSONObject { override fun configuration(): JSONObject {
val c = JSONObject() val c = JSONObject()
try { try {
c.put(rh.gs(info.nightscout.core.utils.R.string.key_absorption_maxtime), sp.getDouble(info.nightscout.core.utils.R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME)) c.put(rh.gs(app.aaps.core.utils.R.string.key_absorption_maxtime), sp.getDouble(app.aaps.core.utils.R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME))
c.put(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_period), sp.getInt(info.nightscout.core.utils.R.string.key_openapsama_autosens_period, 24)) c.put(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_period), sp.getInt(app.aaps.core.utils.R.string.key_openapsama_autosens_period, 24))
c.put(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_max), sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_max, 1.2)) c.put(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_max), sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_autosens_max, 1.2))
c.put(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_min), sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_min, 0.7)) c.put(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_min), sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_autosens_min, 0.7))
} catch (e: JSONException) { } catch (e: JSONException) {
e.printStackTrace() e.printStackTrace()
} }
@ -161,28 +161,28 @@ class SensitivityAAPSPlugin @Inject constructor(
override fun applyConfiguration(configuration: JSONObject) { override fun applyConfiguration(configuration: JSONObject) {
try { try {
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_absorption_maxtime))) sp.putDouble( if (configuration.has(rh.gs(app.aaps.core.utils.R.string.key_absorption_maxtime))) sp.putDouble(
info.nightscout.core.utils.R.string.key_absorption_maxtime, configuration.getDouble( app.aaps.core.utils.R.string.key_absorption_maxtime, configuration.getDouble(
rh.gs( rh.gs(
info.nightscout.core.utils.R.string.key_absorption_maxtime app.aaps.core.utils.R.string.key_absorption_maxtime
) )
) )
) )
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_period))) sp.putDouble( if (configuration.has(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_period))) sp.putDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_period, app.aaps.core.utils.R.string.key_openapsama_autosens_period,
configuration.getDouble(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_period)) configuration.getDouble(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_period))
) )
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_max))) sp.getDouble( if (configuration.has(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_max))) sp.getDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_max, configuration.getDouble( app.aaps.core.utils.R.string.key_openapsama_autosens_max, configuration.getDouble(
rh.gs( rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_max app.aaps.core.utils.R.string.key_openapsama_autosens_max
) )
) )
) )
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_min))) sp.getDouble( if (configuration.has(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_min))) sp.getDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_min, configuration.getDouble( app.aaps.core.utils.R.string.key_openapsama_autosens_min, configuration.getDouble(
rh.gs( rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_min app.aaps.core.utils.R.string.key_openapsama_autosens_min
) )
) )
) )

View file

@ -204,7 +204,7 @@ class SensitivityOref1Plugin @Inject constructor(
return output return output
} }
override fun maxAbsorptionHours(): Double = sp.getDouble(info.nightscout.core.utils.R.string.key_absorption_cutoff, Constants.DEFAULT_MAX_ABSORPTION_TIME) override fun maxAbsorptionHours(): Double = sp.getDouble(app.aaps.core.utils.R.string.key_absorption_cutoff, Constants.DEFAULT_MAX_ABSORPTION_TIME)
override val isMinCarbsAbsorptionDynamic: Boolean = false override val isMinCarbsAbsorptionDynamic: Boolean = false
override val isOref1: Boolean = true override val isOref1: Boolean = true
@ -212,12 +212,12 @@ class SensitivityOref1Plugin @Inject constructor(
val c = JSONObject() val c = JSONObject()
try { try {
c.put( c.put(
rh.gs(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact), rh.gs(app.aaps.core.utils.R.string.key_openapsama_min_5m_carbimpact),
sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact) sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact)
) )
c.put(rh.gs(info.nightscout.core.utils.R.string.key_absorption_cutoff), sp.getDouble(info.nightscout.core.utils.R.string.key_absorption_cutoff, Constants.DEFAULT_MAX_ABSORPTION_TIME)) c.put(rh.gs(app.aaps.core.utils.R.string.key_absorption_cutoff), sp.getDouble(app.aaps.core.utils.R.string.key_absorption_cutoff, Constants.DEFAULT_MAX_ABSORPTION_TIME))
c.put(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_max), sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_max, 1.2)) c.put(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_max), sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_autosens_max, 1.2))
c.put(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_min), sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_min, 0.7)) c.put(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_min), sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_autosens_min, 0.7))
} catch (e: JSONException) { } catch (e: JSONException) {
e.printStackTrace() e.printStackTrace()
} }
@ -226,28 +226,28 @@ class SensitivityOref1Plugin @Inject constructor(
override fun applyConfiguration(configuration: JSONObject) { override fun applyConfiguration(configuration: JSONObject) {
try { try {
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact))) sp.putDouble( if (configuration.has(rh.gs(app.aaps.core.utils.R.string.key_openapsama_min_5m_carbimpact))) sp.putDouble(
info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, app.aaps.core.utils.R.string.key_openapsama_min_5m_carbimpact,
configuration.getDouble(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact)) configuration.getDouble(rh.gs(app.aaps.core.utils.R.string.key_openapsama_min_5m_carbimpact))
) )
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_absorption_cutoff))) sp.putDouble( if (configuration.has(rh.gs(app.aaps.core.utils.R.string.key_absorption_cutoff))) sp.putDouble(
info.nightscout.core.utils.R.string.key_absorption_cutoff, configuration.getDouble( app.aaps.core.utils.R.string.key_absorption_cutoff, configuration.getDouble(
rh.gs( rh.gs(
info.nightscout.core.utils.R.string.key_absorption_cutoff app.aaps.core.utils.R.string.key_absorption_cutoff
) )
) )
) )
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_max))) sp.getDouble( if (configuration.has(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_max))) sp.getDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_max, configuration.getDouble( app.aaps.core.utils.R.string.key_openapsama_autosens_max, configuration.getDouble(
rh.gs( rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_max app.aaps.core.utils.R.string.key_openapsama_autosens_max
) )
) )
) )
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_min))) sp.getDouble( if (configuration.has(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_min))) sp.getDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_min, configuration.getDouble( app.aaps.core.utils.R.string.key_openapsama_autosens_min, configuration.getDouble(
rh.gs( rh.gs(
info.nightscout.core.utils.R.string.key_openapsama_autosens_min app.aaps.core.utils.R.string.key_openapsama_autosens_min
) )
) )
) )

View file

@ -48,12 +48,12 @@ class SensitivityWeightedAveragePlugin @Inject constructor(
) { ) {
override fun detectSensitivity(ads: AutosensDataStore, fromTime: Long, toTime: Long): AutosensResult { override fun detectSensitivity(ads: AutosensDataStore, fromTime: Long, toTime: Long): AutosensResult {
val age = sp.getString(info.nightscout.core.utils.R.string.key_age, "") val age = sp.getString(app.aaps.core.utils.R.string.key_age, "")
var defaultHours = 24 var defaultHours = 24
if (age == rh.gs(info.nightscout.core.utils.R.string.key_adult)) defaultHours = 24 if (age == rh.gs(app.aaps.core.utils.R.string.key_adult)) defaultHours = 24
if (age == rh.gs(info.nightscout.core.utils.R.string.key_teenage)) defaultHours = 4 if (age == rh.gs(app.aaps.core.utils.R.string.key_teenage)) defaultHours = 4
if (age == rh.gs(info.nightscout.core.utils.R.string.key_child)) defaultHours = 4 if (age == rh.gs(app.aaps.core.utils.R.string.key_child)) defaultHours = 4
val hoursForDetection = sp.getInt(info.nightscout.core.utils.R.string.key_openapsama_autosens_period, defaultHours) val hoursForDetection = sp.getInt(app.aaps.core.utils.R.string.key_openapsama_autosens_period, defaultHours)
if (ads.autosensDataTable.size() < 4) { if (ads.autosensDataTable.size() < 4) {
aapsLogger.debug(LTag.AUTOSENS, "No autosens data available. lastDataTime=" + ads.lastDataTime(dateUtil)) aapsLogger.debug(LTag.AUTOSENS, "No autosens data available. lastDataTime=" + ads.lastDataTime(dateUtil))
return AutosensResult() return AutosensResult()
@ -159,7 +159,7 @@ class SensitivityWeightedAveragePlugin @Inject constructor(
return output return output
} }
override fun maxAbsorptionHours(): Double = sp.getDouble(info.nightscout.core.utils.R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME) override fun maxAbsorptionHours(): Double = sp.getDouble(app.aaps.core.utils.R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME)
override val isMinCarbsAbsorptionDynamic: Boolean = true override val isMinCarbsAbsorptionDynamic: Boolean = true
override val isOref1: Boolean = false override val isOref1: Boolean = false
@ -169,10 +169,10 @@ class SensitivityWeightedAveragePlugin @Inject constructor(
override fun configuration(): JSONObject { override fun configuration(): JSONObject {
val c = JSONObject() val c = JSONObject()
try { try {
c.put(rh.gs(info.nightscout.core.utils.R.string.key_absorption_maxtime), sp.getDouble(info.nightscout.core.utils.R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME)) c.put(rh.gs(app.aaps.core.utils.R.string.key_absorption_maxtime), sp.getDouble(app.aaps.core.utils.R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME))
c.put(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_period), sp.getInt(info.nightscout.core.utils.R.string.key_openapsama_autosens_period, 24)) c.put(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_period), sp.getInt(app.aaps.core.utils.R.string.key_openapsama_autosens_period, 24))
c.put(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_max), sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_max, 1.2)) c.put(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_max), sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_autosens_max, 1.2))
c.put(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_min), sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_min, 0.7)) c.put(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_min), sp.getDouble(app.aaps.core.utils.R.string.key_openapsama_autosens_min, 0.7))
} catch (e: JSONException) { } catch (e: JSONException) {
e.printStackTrace() e.printStackTrace()
} }
@ -181,23 +181,23 @@ class SensitivityWeightedAveragePlugin @Inject constructor(
override fun applyConfiguration(configuration: JSONObject) { override fun applyConfiguration(configuration: JSONObject) {
try { try {
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_absorption_maxtime))) sp.putDouble( if (configuration.has(rh.gs(app.aaps.core.utils.R.string.key_absorption_maxtime))) sp.putDouble(
info.nightscout.core.utils.R.string.key_absorption_maxtime, configuration.getDouble( app.aaps.core.utils.R.string.key_absorption_maxtime, configuration.getDouble(
rh.gs(info.nightscout.core.utils.R.string.key_absorption_maxtime) rh.gs(app.aaps.core.utils.R.string.key_absorption_maxtime)
) )
) )
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_period))) sp.putDouble( if (configuration.has(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_period))) sp.putDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_period, app.aaps.core.utils.R.string.key_openapsama_autosens_period,
configuration.getDouble(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_period)) configuration.getDouble(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_period))
) )
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_max))) sp.getDouble( if (configuration.has(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_max))) sp.getDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_max, configuration.getDouble( app.aaps.core.utils.R.string.key_openapsama_autosens_max, configuration.getDouble(
rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_max) rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_max)
) )
) )
if (configuration.has(rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_min))) sp.getDouble( if (configuration.has(rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_min))) sp.getDouble(
info.nightscout.core.utils.R.string.key_openapsama_autosens_min, configuration.getDouble( app.aaps.core.utils.R.string.key_openapsama_autosens_min, configuration.getDouble(
rh.gs(info.nightscout.core.utils.R.string.key_openapsama_autosens_min) rh.gs(app.aaps.core.utils.R.string.key_openapsama_autosens_min)
) )
) )
} catch (e: JSONException) { } catch (e: JSONException) {

View file

@ -84,7 +84,7 @@ class NsIncomingDataProcessor @Inject constructor(
@Suppress("SpellCheckingInspection") @Suppress("SpellCheckingInspection")
fun processSgvs(sgvs: Any) { fun processSgvs(sgvs: Any) {
if (!nsClientSource.isEnabled() && !sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_cgm, false)) return if (!nsClientSource.isEnabled() && !sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_cgm, false)) return
var latestDateInReceivedData: Long = 0 var latestDateInReceivedData: Long = 0
aapsLogger.debug(LTag.NSCLIENT, "Received NS Data: $sgvs") aapsLogger.debug(LTag.NSCLIENT, "Received NS Data: $sgvs")
@ -123,15 +123,15 @@ class NsIncomingDataProcessor @Inject constructor(
when (treatment) { when (treatment) {
is NSBolus -> is NSBolus ->
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_insulin, false) || config.NSCLIENT) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_insulin, false) || config.NSCLIENT)
storeDataForDb.boluses.add(treatment.toBolus()) storeDataForDb.boluses.add(treatment.toBolus())
is NSCarbs -> is NSCarbs ->
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_carbs, false) || config.NSCLIENT) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_carbs, false) || config.NSCLIENT)
storeDataForDb.carbs.add(treatment.toCarbs()) storeDataForDb.carbs.add(treatment.toCarbs())
is NSTemporaryTarget -> is NSTemporaryTarget ->
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_temp_target, false) || config.NSCLIENT) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_temp_target, false) || config.NSCLIENT) {
if (treatment.duration > 0L) { if (treatment.duration > 0L) {
// not ending event // not ending event
if (treatment.targetBottomAsMgdl() < Constants.MIN_TT_MGDL if (treatment.targetBottomAsMgdl() < Constants.MIN_TT_MGDL
@ -152,14 +152,14 @@ class NsIncomingDataProcessor @Inject constructor(
storeDataForDb.temporaryBasals.add(treatment.toTemporaryBasal()) storeDataForDb.temporaryBasals.add(treatment.toTemporaryBasal())
is NSEffectiveProfileSwitch -> is NSEffectiveProfileSwitch ->
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_profile_switch, false) || config.NSCLIENT) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_profile_switch, false) || config.NSCLIENT) {
treatment.toEffectiveProfileSwitch(dateUtil)?.let { effectiveProfileSwitch -> treatment.toEffectiveProfileSwitch(dateUtil)?.let { effectiveProfileSwitch ->
storeDataForDb.effectiveProfileSwitches.add(effectiveProfileSwitch) storeDataForDb.effectiveProfileSwitches.add(effectiveProfileSwitch)
} }
} }
is NSProfileSwitch -> is NSProfileSwitch ->
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_profile_switch, false) || config.NSCLIENT) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_profile_switch, false) || config.NSCLIENT) {
treatment.toProfileSwitch(activePlugin, dateUtil)?.let { profileSwitch -> treatment.toProfileSwitch(activePlugin, dateUtil)?.let { profileSwitch ->
storeDataForDb.profileSwitches.add(profileSwitch) storeDataForDb.profileSwitches.add(profileSwitch)
} }
@ -171,13 +171,13 @@ class NsIncomingDataProcessor @Inject constructor(
} }
is NSTherapyEvent -> is NSTherapyEvent ->
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_therapy_events, false) || config.NSCLIENT) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_therapy_events, false) || config.NSCLIENT)
treatment.toTherapyEvent().let { therapyEvent -> treatment.toTherapyEvent().let { therapyEvent ->
storeDataForDb.therapyEvents.add(therapyEvent) storeDataForDb.therapyEvents.add(therapyEvent)
} }
is NSOfflineEvent -> is NSOfflineEvent ->
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_offline_event, false) && config.isEngineeringMode() || config.NSCLIENT) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_offline_event, false) && config.isEngineeringMode() || config.NSCLIENT)
treatment.toOfflineEvent().let { offlineEvent -> treatment.toOfflineEvent().let { offlineEvent ->
storeDataForDb.offlineEvents.add(offlineEvent) storeDataForDb.offlineEvents.add(offlineEvent)
} }
@ -237,10 +237,10 @@ class NsIncomingDataProcessor @Inject constructor(
} }
fun processProfile(profileJson: JSONObject) { fun processProfile(profileJson: JSONObject) {
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_profile_store, true) || config.NSCLIENT) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_profile_store, true) || config.NSCLIENT) {
val store = instantiator.provideProfileStore(profileJson) val store = instantiator.provideProfileStore(profileJson)
val createdAt = store.getStartDate() val createdAt = store.getStartDate()
val lastLocalChange = sp.getLong(info.nightscout.core.utils.R.string.key_local_profile_last_change, 0) val lastLocalChange = sp.getLong(app.aaps.core.utils.R.string.key_local_profile_last_change, 0)
aapsLogger.debug(LTag.PROFILE, "Received profileStore: createdAt: $createdAt Local last modification: $lastLocalChange") aapsLogger.debug(LTag.PROFILE, "Received profileStore: createdAt: $createdAt Local last modification: $lastLocalChange")
if (createdAt > lastLocalChange || createdAt % 1000 == 0L) { // whole second means edited in NS if (createdAt > lastLocalChange || createdAt % 1000 == 0L) { // whole second means edited in NS
profileSource.loadFromStore(store) profileSource.loadFromStore(store)

View file

@ -555,13 +555,13 @@ class StoreDataForDbImpl @Inject constructor(
sendLog("BolusCalculatorResult", BolusCalculatorResult::class.java.simpleName) sendLog("BolusCalculatorResult", BolusCalculatorResult::class.java.simpleName)
SystemClock.sleep(pause) SystemClock.sleep(pause)
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_therapy_events, false) || config.NSCLIENT) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_therapy_events, false) || config.NSCLIENT)
therapyEvents.filter { it.type == TherapyEvent.Type.ANNOUNCEMENT }.forEach { therapyEvents.filter { it.type == TherapyEvent.Type.ANNOUNCEMENT }.forEach {
if (it.timestamp > dateUtil.now() - 15 * 60 * 1000L && if (it.timestamp > dateUtil.now() - 15 * 60 * 1000L &&
it.note?.isNotEmpty() == true && it.note?.isNotEmpty() == true &&
it.enteredBy != sp.getString("careportal_enteredby", "AndroidAPS") it.enteredBy != sp.getString("careportal_enteredby", "AndroidAPS")
) { ) {
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_announcements, config.NSCLIENT)) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_announcements, config.NSCLIENT))
uiInteraction.addNotificationValidFor(Notification.NS_ANNOUNCEMENT, it.note ?: "", Notification.ANNOUNCEMENT, 60) uiInteraction.addNotificationValidFor(Notification.NS_ANNOUNCEMENT, it.note ?: "", Notification.ANNOUNCEMENT, 60)
} }
} }
@ -977,7 +977,7 @@ class StoreDataForDbImpl @Inject constructor(
override fun updateDeletedTreatmentsInDb() { override fun updateDeletedTreatmentsInDb() {
deleteTreatment.forEach { id -> deleteTreatment.forEach { id ->
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_insulin, false) || config.NSCLIENT) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_insulin, false) || config.NSCLIENT)
repository.findBolusByNSId(id)?.let { bolus -> repository.findBolusByNSId(id)?.let { bolus ->
repository.runTransactionForResult(InvalidateBolusTransaction(bolus.id)) repository.runTransactionForResult(InvalidateBolusTransaction(bolus.id))
.doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating Bolus", it) } .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating Bolus", it) }
@ -989,7 +989,7 @@ class StoreDataForDbImpl @Inject constructor(
} }
} }
} }
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_carbs, false) || config.NSCLIENT) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_carbs, false) || config.NSCLIENT)
repository.findCarbsByNSId(id)?.let { carb -> repository.findCarbsByNSId(id)?.let { carb ->
repository.runTransactionForResult(InvalidateCarbsTransaction(carb.id)) repository.runTransactionForResult(InvalidateCarbsTransaction(carb.id))
.doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating Carbs", it) } .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating Carbs", it) }
@ -1001,7 +1001,7 @@ class StoreDataForDbImpl @Inject constructor(
} }
} }
} }
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_temp_target, false) || config.NSCLIENT) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_temp_target, false) || config.NSCLIENT)
repository.findTemporaryTargetByNSId(id)?.let { gv -> repository.findTemporaryTargetByNSId(id)?.let { gv ->
repository.runTransactionForResult(InvalidateTemporaryTargetTransaction(gv.id)) repository.runTransactionForResult(InvalidateTemporaryTargetTransaction(gv.id))
.doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating TemporaryTarget", it) } .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating TemporaryTarget", it) }
@ -1025,7 +1025,7 @@ class StoreDataForDbImpl @Inject constructor(
} }
} }
} }
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_profile_switch, false) || config.NSCLIENT) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_profile_switch, false) || config.NSCLIENT)
repository.findEffectiveProfileSwitchByNSId(id)?.let { gv -> repository.findEffectiveProfileSwitchByNSId(id)?.let { gv ->
repository.runTransactionForResult(InvalidateEffectiveProfileSwitchTransaction(gv.id)) repository.runTransactionForResult(InvalidateEffectiveProfileSwitchTransaction(gv.id))
.doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating EffectiveProfileSwitch", it) } .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating EffectiveProfileSwitch", it) }
@ -1037,7 +1037,7 @@ class StoreDataForDbImpl @Inject constructor(
} }
} }
} }
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_profile_switch, false) || config.NSCLIENT) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_profile_switch, false) || config.NSCLIENT)
repository.findProfileSwitchByNSId(id)?.let { gv -> repository.findProfileSwitchByNSId(id)?.let { gv ->
repository.runTransactionForResult(InvalidateProfileSwitchTransaction(gv.id)) repository.runTransactionForResult(InvalidateProfileSwitchTransaction(gv.id))
.doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating ProfileSwitch", it) } .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating ProfileSwitch", it) }
@ -1060,7 +1060,7 @@ class StoreDataForDbImpl @Inject constructor(
} }
} }
} }
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_therapy_events, false) || config.NSCLIENT) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_therapy_events, false) || config.NSCLIENT)
repository.findTherapyEventByNSId(id)?.let { gv -> repository.findTherapyEventByNSId(id)?.let { gv ->
repository.runTransactionForResult(InvalidateTherapyEventTransaction(gv.id)) repository.runTransactionForResult(InvalidateTherapyEventTransaction(gv.id))
.doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating TherapyEvent", it) } .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating TherapyEvent", it) }
@ -1072,7 +1072,7 @@ class StoreDataForDbImpl @Inject constructor(
} }
} }
} }
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_offline_event, false) && config.isEngineeringMode() || config.NSCLIENT) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_offline_event, false) && config.isEngineeringMode() || config.NSCLIENT)
repository.findOfflineEventByNSId(id)?.let { gv -> repository.findOfflineEventByNSId(id)?.let { gv ->
repository.runTransactionForResult(InvalidateOfflineEventTransaction(gv.id)) repository.runTransactionForResult(InvalidateOfflineEventTransaction(gv.id))
.doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating OfflineEvent", it) } .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating OfflineEvent", it) }

View file

@ -76,7 +76,7 @@ class DataSyncSelectorV1 @Inject constructor(
private var running = false private var running = false
private val sync = Any() private val sync = Any()
private val bgUploadEnabled get() = sp.getBoolean(info.nightscout.core.utils.R.string.key_do_ns_upload, false) && activePlugin.activeBgSource !is NSClientSource private val bgUploadEnabled get() = sp.getBoolean(app.aaps.core.utils.R.string.key_do_ns_upload, false) && activePlugin.activeBgSource !is NSClientSource
override suspend fun doUpload() { override suspend fun doUpload() {
synchronized(sync) { synchronized(sync) {
@ -782,7 +782,7 @@ class DataSyncSelectorV1 @Inject constructor(
private suspend fun processChangedProfileStore() { private suspend fun processChangedProfileStore() {
if (isPaused) return if (isPaused) return
val lastSync = sp.getLong(R.string.key_ns_profile_store_last_synced_timestamp, 0) val lastSync = sp.getLong(R.string.key_ns_profile_store_last_synced_timestamp, 0)
val lastChange = sp.getLong(info.nightscout.core.utils.R.string.key_local_profile_last_change, 0) val lastChange = sp.getLong(app.aaps.core.utils.R.string.key_local_profile_last_change, 0)
if (lastChange == 0L) return if (lastChange == 0L) return
if (lastChange > lastSync) { if (lastChange > lastSync) {
if (activePlugin.activeProfileSource.profile?.allProfilesValid != true) return if (activePlugin.activeProfileSource.profile?.allProfilesValid != true) return

View file

@ -124,8 +124,8 @@ class NSClientPlugin @Inject constructor(
if (config.NSCLIENT) { if (config.NSCLIENT) {
preferenceFragment.findPreference<PreferenceScreen>(rh.gs(R.string.ns_sync_options))?.isVisible = false preferenceFragment.findPreference<PreferenceScreen>(rh.gs(R.string.ns_sync_options))?.isVisible = false
preferenceFragment.findPreference<SwitchPreference>(rh.gs(info.nightscout.core.utils.R.string.key_ns_create_announcements_from_errors))?.isVisible = false preferenceFragment.findPreference<SwitchPreference>(rh.gs(app.aaps.core.utils.R.string.key_ns_create_announcements_from_errors))?.isVisible = false
preferenceFragment.findPreference<SwitchPreference>(rh.gs(info.nightscout.core.utils.R.string.key_ns_create_announcements_from_carbs_req))?.isVisible = false preferenceFragment.findPreference<SwitchPreference>(rh.gs(app.aaps.core.utils.R.string.key_ns_create_announcements_from_carbs_req))?.isVisible = false
} }
preferenceFragment.findPreference<SwitchPreference>(rh.gs(R.string.key_ns_receive_tbr_eb))?.isVisible = config.isEngineeringMode() preferenceFragment.findPreference<SwitchPreference>(rh.gs(R.string.key_ns_receive_tbr_eb))?.isVisible = config.isEngineeringMode()
} }

View file

@ -83,7 +83,7 @@ class NSDeviceStatusHandler @Inject constructor(
updateDeviceData(nsDeviceStatus) updateDeviceData(nsDeviceStatus)
updateOpenApsData(nsDeviceStatus) updateOpenApsData(nsDeviceStatus)
updateUploaderData(nsDeviceStatus) updateUploaderData(nsDeviceStatus)
nsDeviceStatus.pump?.let { sp.putBoolean(info.nightscout.core.utils.R.string.key_objectives_pump_status_is_available_in_ns, true) } // Objective 0 nsDeviceStatus.pump?.let { sp.putBoolean(app.aaps.core.utils.R.string.key_objectives_pump_status_is_available_in_ns, true) } // Objective 0
if (config.NSCLIENT && !configurationDetected) if (config.NSCLIENT && !configurationDetected)
nsDeviceStatus.configuration?.let { nsDeviceStatus.configuration?.let {
// copy configuration of Insulin and Sensitivity from main AAPS // copy configuration of Insulin and Sensitivity from main AAPS

View file

@ -238,14 +238,14 @@ class NSSettingsStatusImpl @Inject constructor(
override fun copyStatusLightsNsSettings(context: Context?) { override fun copyStatusLightsNsSettings(context: Context?) {
val action = Runnable { val action = Runnable {
getExtendedWarnValue("cage", "warn")?.let { sp.putDouble(info.nightscout.core.utils.R.string.key_statuslights_cage_warning, it) } getExtendedWarnValue("cage", "warn")?.let { sp.putDouble(app.aaps.core.utils.R.string.key_statuslights_cage_warning, it) }
getExtendedWarnValue("cage", "urgent")?.let { sp.putDouble(info.nightscout.core.utils.R.string.key_statuslights_cage_critical, it) } getExtendedWarnValue("cage", "urgent")?.let { sp.putDouble(app.aaps.core.utils.R.string.key_statuslights_cage_critical, it) }
getExtendedWarnValue("iage", "warn")?.let { sp.putDouble(info.nightscout.core.utils.R.string.key_statuslights_iage_warning, it) } getExtendedWarnValue("iage", "warn")?.let { sp.putDouble(app.aaps.core.utils.R.string.key_statuslights_iage_warning, it) }
getExtendedWarnValue("iage", "urgent")?.let { sp.putDouble(info.nightscout.core.utils.R.string.key_statuslights_iage_critical, it) } getExtendedWarnValue("iage", "urgent")?.let { sp.putDouble(app.aaps.core.utils.R.string.key_statuslights_iage_critical, it) }
getExtendedWarnValue("sage", "warn")?.let { sp.putDouble(info.nightscout.core.utils.R.string.key_statuslights_sage_warning, it) } getExtendedWarnValue("sage", "warn")?.let { sp.putDouble(app.aaps.core.utils.R.string.key_statuslights_sage_warning, it) }
getExtendedWarnValue("sage", "urgent")?.let { sp.putDouble(info.nightscout.core.utils.R.string.key_statuslights_sage_critical, it) } getExtendedWarnValue("sage", "urgent")?.let { sp.putDouble(app.aaps.core.utils.R.string.key_statuslights_sage_critical, it) }
getExtendedWarnValue("bage", "warn")?.let { sp.putDouble(info.nightscout.core.utils.R.string.key_statuslights_bage_warning, it) } getExtendedWarnValue("bage", "warn")?.let { sp.putDouble(app.aaps.core.utils.R.string.key_statuslights_bage_warning, it) }
getExtendedWarnValue("bage", "urgent")?.let { sp.putDouble(info.nightscout.core.utils.R.string.key_statuslights_bage_critical, it) } getExtendedWarnValue("bage", "urgent")?.let { sp.putDouble(app.aaps.core.utils.R.string.key_statuslights_bage_critical, it) }
uel.log(Action.NS_SETTINGS_COPIED, UserEntry.Sources.NSClient) uel.log(Action.NS_SETTINGS_COPIED, UserEntry.Sources.NSClient)
} }

View file

@ -101,10 +101,10 @@ class ProcessedDeviceStatusDataImpl @Inject constructor(
// test warning level // test warning level
val level = when { val level = when {
openAPSData.clockSuggested + T.mins(sp.getLong(info.nightscout.core.utils.R.string.key_ns_alarm_urgent_stale_data_value, 31)) openAPSData.clockSuggested + T.mins(sp.getLong(app.aaps.core.utils.R.string.key_ns_alarm_urgent_stale_data_value, 31))
.msecs() < dateUtil.now() -> ProcessedDeviceStatusData.Levels.URGENT .msecs() < dateUtil.now() -> ProcessedDeviceStatusData.Levels.URGENT
openAPSData.clockSuggested + T.mins(sp.getLong(info.nightscout.core.utils.R.string.key_ns_alarm_stale_data_value, 16)).msecs() < dateUtil.now() -> ProcessedDeviceStatusData.Levels.WARN openAPSData.clockSuggested + T.mins(sp.getLong(app.aaps.core.utils.R.string.key_ns_alarm_stale_data_value, 16)).msecs() < dateUtil.now() -> ProcessedDeviceStatusData.Levels.WARN
else -> ProcessedDeviceStatusData.Levels.INFO else -> ProcessedDeviceStatusData.Levels.INFO
} }
string.append("<span style=\"color:${level.toColor()}\">") string.append("<span style=\"color:${level.toColor()}\">")

View file

@ -137,8 +137,8 @@ import javax.inject.Inject
.toObservable(EventPreferenceChange::class.java) .toObservable(EventPreferenceChange::class.java)
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribe({ event: EventPreferenceChange -> .subscribe({ event: EventPreferenceChange ->
if (event.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_nsclientinternal_url)) || if (event.isChanged(rh.gs(app.aaps.core.utils.R.string.key_nsclientinternal_url)) ||
event.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_nsclientinternal_api_secret)) || event.isChanged(rh.gs(app.aaps.core.utils.R.string.key_nsclientinternal_api_secret)) ||
event.isChanged(rh.gs(R.string.key_ns_paused)) event.isChanged(rh.gs(R.string.key_ns_paused))
) { ) {
latestDateInReceivedData = 0 latestDateInReceivedData = 0
@ -360,8 +360,8 @@ import javax.inject.Inject
private fun readPreferences() { private fun readPreferences() {
nsEnabled = nsClientPlugin.isEnabled() nsEnabled = nsClientPlugin.isEnabled()
nsURL = sp.getString(info.nightscout.core.utils.R.string.key_nsclientinternal_url, "") nsURL = sp.getString(app.aaps.core.utils.R.string.key_nsclientinternal_url, "")
nsAPISecret = sp.getString(info.nightscout.core.utils.R.string.key_nsclientinternal_api_secret, "") nsAPISecret = sp.getString(app.aaps.core.utils.R.string.key_nsclientinternal_api_secret, "")
nsDevice = sp.getString("careportal_enteredby", "") nsDevice = sp.getString("careportal_enteredby", "")
} }
@ -557,7 +557,7 @@ import javax.inject.Inject
if (sgvs.length() > 0) { if (sgvs.length() > 0) {
rxBus.send(EventNSClientNewLog("◄ DATA", "received " + sgvs.length() + " sgvs")) rxBus.send(EventNSClientNewLog("◄ DATA", "received " + sgvs.length() + " sgvs"))
// Objective0 // Objective0
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectives_bg_is_available_in_ns, true) sp.putBoolean(app.aaps.core.utils.R.string.key_objectives_bg_is_available_in_ns, true)
nsIncomingDataProcessor.processSgvs(sgvs) nsIncomingDataProcessor.processSgvs(sgvs)
storeDataForDb.storeGlucoseValuesToDb() storeDataForDb.storeGlucoseValuesToDb()
} }
@ -635,7 +635,7 @@ import javax.inject.Inject
private fun handleAnnouncement(announcement: JSONObject) { private fun handleAnnouncement(announcement: JSONObject) {
val defaultVal = config.NSCLIENT val defaultVal = config.NSCLIENT
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_announcements, defaultVal)) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_announcements, defaultVal)) {
val nsAlarm = NSAlarmObject(announcement) val nsAlarm = NSAlarmObject(announcement)
uiInteraction.addNotificationWithAction(injector, nsAlarm) uiInteraction.addNotificationWithAction(injector, nsAlarm)
rxBus.send(EventNSClientNewLog("◄ ANNOUNCEMENT", safeGetString(announcement, "message", "received"))) rxBus.send(EventNSClientNewLog("◄ ANNOUNCEMENT", safeGetString(announcement, "message", "received")))
@ -645,8 +645,8 @@ import javax.inject.Inject
private fun handleAlarm(alarm: JSONObject) { private fun handleAlarm(alarm: JSONObject) {
val defaultVal = config.NSCLIENT val defaultVal = config.NSCLIENT
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_alarms, defaultVal)) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_alarms, defaultVal)) {
val snoozedTo = sp.getLong(rh.gs(info.nightscout.core.utils.R.string.key_snoozed_to) + alarm.optString("level"), 0L) val snoozedTo = sp.getLong(rh.gs(app.aaps.core.utils.R.string.key_snoozed_to) + alarm.optString("level"), 0L)
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
val nsAlarm = NSAlarmObject(alarm) val nsAlarm = NSAlarmObject(alarm)
uiInteraction.addNotificationWithAction(injector, nsAlarm) uiInteraction.addNotificationWithAction(injector, nsAlarm)
@ -658,8 +658,8 @@ import javax.inject.Inject
private fun handleUrgentAlarm(alarm: JSONObject) { private fun handleUrgentAlarm(alarm: JSONObject) {
val defaultVal = config.NSCLIENT val defaultVal = config.NSCLIENT
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_alarms, defaultVal)) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_alarms, defaultVal)) {
val snoozedTo = sp.getLong(rh.gs(info.nightscout.core.utils.R.string.key_snoozed_to) + alarm.optString("level"), 0L) val snoozedTo = sp.getLong(rh.gs(app.aaps.core.utils.R.string.key_snoozed_to) + alarm.optString("level"), 0L)
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
val nsAlarm = NSAlarmObject(alarm) val nsAlarm = NSAlarmObject(alarm)
uiInteraction.addNotificationWithAction(injector, nsAlarm) uiInteraction.addNotificationWithAction(injector, nsAlarm)

View file

@ -72,14 +72,14 @@ class NSClientAddUpdateWorker(
if (mills > latestDateInReceivedData) latestDateInReceivedData = mills if (mills > latestDateInReceivedData) latestDateInReceivedData = mills
if (insulin > 0) { if (insulin > 0) {
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_insulin, false) || config.NSCLIENT) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_insulin, false) || config.NSCLIENT) {
Bolus.fromJson(json)?.let { bolus -> Bolus.fromJson(json)?.let { bolus ->
storeDataForDb.boluses.add(bolus) storeDataForDb.boluses.add(bolus)
} ?: aapsLogger.error("Error parsing bolus json $json") } ?: aapsLogger.error("Error parsing bolus json $json")
} }
} }
if (carbs > 0) { if (carbs > 0) {
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_carbs, false) || config.NSCLIENT) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_carbs, false) || config.NSCLIENT) {
Carbs.fromJson(json)?.let { carb -> Carbs.fromJson(json)?.let { carb ->
storeDataForDb.carbs.add(carb) storeDataForDb.carbs.add(carb)
} ?: aapsLogger.error("Error parsing bolus json $json") } ?: aapsLogger.error("Error parsing bolus json $json")
@ -99,14 +99,14 @@ class NSClientAddUpdateWorker(
when { when {
insulin > 0 || carbs > 0 -> Any() insulin > 0 || carbs > 0 -> Any()
eventType == TherapyEvent.Type.TEMPORARY_TARGET.text -> eventType == TherapyEvent.Type.TEMPORARY_TARGET.text ->
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_temp_target, false) || config.NSCLIENT) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_temp_target, false) || config.NSCLIENT) {
TemporaryTarget.fromJson(json, profileUtil)?.let { temporaryTarget -> TemporaryTarget.fromJson(json, profileUtil)?.let { temporaryTarget ->
storeDataForDb.temporaryTargets.add(temporaryTarget) storeDataForDb.temporaryTargets.add(temporaryTarget)
} ?: aapsLogger.error("Error parsing TT json $json") } ?: aapsLogger.error("Error parsing TT json $json")
} }
eventType == TherapyEvent.Type.NOTE.text && json.isEffectiveProfileSwitch() -> // replace this by new Type when available in NS eventType == TherapyEvent.Type.NOTE.text && json.isEffectiveProfileSwitch() -> // replace this by new Type when available in NS
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_profile_switch, false) || config.NSCLIENT) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_profile_switch, false) || config.NSCLIENT) {
EffectiveProfileSwitch.fromJson(json, dateUtil)?.let { effectiveProfileSwitch -> EffectiveProfileSwitch.fromJson(json, dateUtil)?.let { effectiveProfileSwitch ->
storeDataForDb.effectiveProfileSwitches.add(effectiveProfileSwitch) storeDataForDb.effectiveProfileSwitches.add(effectiveProfileSwitch)
} ?: aapsLogger.error("Error parsing EffectiveProfileSwitch json $json") } ?: aapsLogger.error("Error parsing EffectiveProfileSwitch json $json")
@ -127,7 +127,7 @@ class NSClientAddUpdateWorker(
eventType == TherapyEvent.Type.EXERCISE.text || eventType == TherapyEvent.Type.EXERCISE.text ||
eventType == TherapyEvent.Type.NOTE.text || eventType == TherapyEvent.Type.NOTE.text ||
eventType == TherapyEvent.Type.PUMP_BATTERY_CHANGE.text -> eventType == TherapyEvent.Type.PUMP_BATTERY_CHANGE.text ->
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_therapy_events, false) || config.NSCLIENT) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_therapy_events, false) || config.NSCLIENT) {
TherapyEvent.fromJson(json)?.let { therapyEvent -> TherapyEvent.fromJson(json)?.let { therapyEvent ->
storeDataForDb.therapyEvents.add(therapyEvent) storeDataForDb.therapyEvents.add(therapyEvent)
} ?: aapsLogger.error("Error parsing TherapyEvent json $json") } ?: aapsLogger.error("Error parsing TherapyEvent json $json")
@ -148,14 +148,14 @@ class NSClientAddUpdateWorker(
} }
eventType == TherapyEvent.Type.PROFILE_SWITCH.text -> eventType == TherapyEvent.Type.PROFILE_SWITCH.text ->
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_profile_switch, false) || config.NSCLIENT) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_profile_switch, false) || config.NSCLIENT) {
ProfileSwitch.fromJson(json, dateUtil, activePlugin)?.let { profileSwitch -> ProfileSwitch.fromJson(json, dateUtil, activePlugin)?.let { profileSwitch ->
storeDataForDb.profileSwitches.add(profileSwitch) storeDataForDb.profileSwitches.add(profileSwitch)
} ?: aapsLogger.error("Error parsing ProfileSwitch json $json") } ?: aapsLogger.error("Error parsing ProfileSwitch json $json")
} }
eventType == TherapyEvent.Type.APS_OFFLINE.text -> eventType == TherapyEvent.Type.APS_OFFLINE.text ->
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_offline_event, false) && config.isEngineeringMode() || config.NSCLIENT) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_offline_event, false) && config.isEngineeringMode() || config.NSCLIENT) {
OfflineEvent.fromJson(json)?.let { offlineEvent -> OfflineEvent.fromJson(json)?.let { offlineEvent ->
storeDataForDb.offlineEvents.add(offlineEvent) storeDataForDb.offlineEvents.add(offlineEvent)
} ?: aapsLogger.error("Error parsing OfflineEvent json $json") } ?: aapsLogger.error("Error parsing OfflineEvent json $json")

View file

@ -26,7 +26,7 @@ class NSClientMbgWorker(
override suspend fun doWorkAndLog(): Result { override suspend fun doWorkAndLog(): Result {
val ret = Result.success() val ret = Result.success()
val acceptNSData = sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_therapy_events, false) || config.NSCLIENT val acceptNSData = sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_therapy_events, false) || config.NSCLIENT
if (!acceptNSData) return Result.success(workDataOf("Result" to "Sync not enabled")) if (!acceptNSData) return Result.success(workDataOf("Result" to "Sync not enabled"))
val mbgArray = dataWorkerStorage.pickupJSONArray(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) val mbgArray = dataWorkerStorage.pickupJSONArray(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))

View file

@ -71,7 +71,7 @@ class DataSyncSelectorV3 @Inject constructor(
override fun queueSize(): Long = queueCounter.size() override fun queueSize(): Long = queueCounter.size()
private val bgUploadEnabled get() = sp.getBoolean(info.nightscout.core.utils.R.string.key_do_ns_upload, false) && activePlugin.activeBgSource !is NSClientSource private val bgUploadEnabled get() = sp.getBoolean(app.aaps.core.utils.R.string.key_do_ns_upload, false) && activePlugin.activeBgSource !is NSClientSource
override suspend fun doUpload() { override suspend fun doUpload() {
rxBus.send(EventNSClientUpdateGuiStatus()) rxBus.send(EventNSClientUpdateGuiStatus())
@ -675,7 +675,7 @@ class DataSyncSelectorV3 @Inject constructor(
private suspend fun processChangedProfileStore() { private suspend fun processChangedProfileStore() {
if (isPaused) return if (isPaused) return
val lastSync = sp.getLong(R.string.key_ns_profile_store_last_synced_timestamp, 0) val lastSync = sp.getLong(R.string.key_ns_profile_store_last_synced_timestamp, 0)
val lastChange = sp.getLong(info.nightscout.core.utils.R.string.key_local_profile_last_change, 0) val lastChange = sp.getLong(app.aaps.core.utils.R.string.key_local_profile_last_change, 0)
if (lastChange == 0L) return if (lastChange == 0L) return
if (lastChange > lastSync) { if (lastChange > lastSync) {
if (activePlugin.activeProfileSource.profile?.allProfilesValid != true) return if (activePlugin.activeProfileSource.profile?.allProfilesValid != true) return

View file

@ -158,8 +158,8 @@ class NSClientV3Plugin @Inject constructor(
when { when {
sp.getBoolean(R.string.key_ns_paused, false) -> rh.gs(app.aaps.core.ui.R.string.paused) sp.getBoolean(R.string.key_ns_paused, false) -> rh.gs(app.aaps.core.ui.R.string.paused)
isAllowed.not() -> blockingReason isAllowed.not() -> blockingReason
sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_use_ws, true) && wsConnected -> "WS: " + rh.gs(app.aaps.core.interfaces.R.string.connected) sp.getBoolean(app.aaps.core.utils.R.string.key_ns_use_ws, true) && wsConnected -> "WS: " + rh.gs(app.aaps.core.interfaces.R.string.connected)
sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_use_ws, true) && !wsConnected -> "WS: " + rh.gs(R.string.not_connected) sp.getBoolean(app.aaps.core.utils.R.string.key_ns_use_ws, true) && !wsConnected -> "WS: " + rh.gs(R.string.not_connected)
lastOperationError != null -> rh.gs(app.aaps.core.ui.R.string.error) lastOperationError != null -> rh.gs(app.aaps.core.ui.R.string.error)
nsAndroidClient?.lastStatus == null -> rh.gs(R.string.not_connected) nsAndroidClient?.lastStatus == null -> rh.gs(R.string.not_connected)
workIsRunning() -> rh.gs(R.string.working) workIsRunning() -> rh.gs(R.string.working)
@ -206,14 +206,14 @@ class NSClientV3Plugin @Inject constructor(
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribe({ ev -> .subscribe({ ev ->
if (ev.isChanged(rh.gs(R.string.key_ns_client_token)) || if (ev.isChanged(rh.gs(R.string.key_ns_client_token)) ||
ev.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_nsclientinternal_url)) || ev.isChanged(rh.gs(app.aaps.core.utils.R.string.key_nsclientinternal_url)) ||
ev.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_ns_use_ws)) || ev.isChanged(rh.gs(app.aaps.core.utils.R.string.key_ns_use_ws)) ||
ev.isChanged(rh.gs(R.string.key_ns_paused)) || ev.isChanged(rh.gs(R.string.key_ns_paused)) ||
ev.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_ns_alarms)) || ev.isChanged(rh.gs(app.aaps.core.utils.R.string.key_ns_alarms)) ||
ev.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_ns_announcements)) ev.isChanged(rh.gs(app.aaps.core.utils.R.string.key_ns_announcements))
) )
setClient("SETTING CHANGE") setClient("SETTING CHANGE")
if (ev.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_local_profile_last_change))) if (ev.isChanged(rh.gs(app.aaps.core.utils.R.string.key_local_profile_last_change)))
executeUpload("PROFILE_CHANGE", forceNew = true) executeUpload("PROFILE_CHANGE", forceNew = true)
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
@ -268,7 +268,7 @@ class NSClientV3Plugin @Inject constructor(
} }
} }
} }
if (!sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_use_ws, true)) if (!sp.getBoolean(app.aaps.core.utils.R.string.key_ns_use_ws, true))
executeLoop("MAIN_LOOP", forceNew = true) executeLoop("MAIN_LOOP", forceNew = true)
else else
rxBus.send(EventNSClientNewLog("● TICK", "")) rxBus.send(EventNSClientNewLog("● TICK", ""))
@ -311,8 +311,8 @@ class NSClientV3Plugin @Inject constructor(
if (config.NSCLIENT) { if (config.NSCLIENT) {
preferenceFragment.findPreference<PreferenceScreen>(rh.gs(R.string.ns_sync_options))?.isVisible = false preferenceFragment.findPreference<PreferenceScreen>(rh.gs(R.string.ns_sync_options))?.isVisible = false
preferenceFragment.findPreference<SwitchPreference>(rh.gs(info.nightscout.core.utils.R.string.key_ns_create_announcements_from_errors))?.isVisible = false preferenceFragment.findPreference<SwitchPreference>(rh.gs(app.aaps.core.utils.R.string.key_ns_create_announcements_from_errors))?.isVisible = false
preferenceFragment.findPreference<SwitchPreference>(rh.gs(info.nightscout.core.utils.R.string.key_ns_create_announcements_from_carbs_req))?.isVisible = false preferenceFragment.findPreference<SwitchPreference>(rh.gs(app.aaps.core.utils.R.string.key_ns_create_announcements_from_carbs_req))?.isVisible = false
} }
preferenceFragment.findPreference<SwitchPreference>(rh.gs(R.string.key_ns_receive_tbr_eb))?.isVisible = config.isEngineeringMode() preferenceFragment.findPreference<SwitchPreference>(rh.gs(R.string.key_ns_receive_tbr_eb))?.isVisible = config.isEngineeringMode()
} }
@ -332,7 +332,7 @@ class NSClientV3Plugin @Inject constructor(
private fun setClient(reason: String) { private fun setClient(reason: String) {
nsAndroidClient = NSAndroidClientImpl( nsAndroidClient = NSAndroidClientImpl(
baseUrl = sp.getString(info.nightscout.core.utils.R.string.key_nsclientinternal_url, "").lowercase().replace("https://", "").replace(Regex("/$"), ""), baseUrl = sp.getString(app.aaps.core.utils.R.string.key_nsclientinternal_url, "").lowercase().replace("https://", "").replace(Regex("/$"), ""),
accessToken = sp.getString(R.string.key_ns_client_token, ""), accessToken = sp.getString(R.string.key_ns_client_token, ""),
context = context, context = context,
logging = true, logging = true,
@ -357,10 +357,10 @@ class NSClientV3Plugin @Inject constructor(
var wsConnected = false var wsConnected = false
internal var initialLoadFinished = false internal var initialLoadFinished = false
private fun initializeWebSockets(reason: String) { private fun initializeWebSockets(reason: String) {
if (!sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_use_ws, true)) return if (!sp.getBoolean(app.aaps.core.utils.R.string.key_ns_use_ws, true)) return
if (sp.getString(info.nightscout.core.utils.R.string.key_nsclientinternal_url, "").isEmpty()) return if (sp.getString(app.aaps.core.utils.R.string.key_nsclientinternal_url, "").isEmpty()) return
val urlStorage = sp.getString(info.nightscout.core.utils.R.string.key_nsclientinternal_url, "").lowercase().replace(Regex("/$"), "") + "/storage" val urlStorage = sp.getString(app.aaps.core.utils.R.string.key_nsclientinternal_url, "").lowercase().replace(Regex("/$"), "") + "/storage"
val urlAlarm = sp.getString(info.nightscout.core.utils.R.string.key_nsclientinternal_url, "").lowercase().replace(Regex("/$"), "") + "/alarm" val urlAlarm = sp.getString(app.aaps.core.utils.R.string.key_nsclientinternal_url, "").lowercase().replace(Regex("/$"), "") + "/alarm"
if (!isAllowed) { if (!isAllowed) {
rxBus.send(EventNSClientNewLog("● WS", blockingReason)) rxBus.send(EventNSClientNewLog("● WS", blockingReason))
} else if (sp.getBoolean(R.string.key_ns_paused, false)) { } else if (sp.getBoolean(R.string.key_ns_paused, false)) {
@ -377,8 +377,8 @@ class NSClientV3Plugin @Inject constructor(
socket.on("update", onDataCreateUpdate) socket.on("update", onDataCreateUpdate)
socket.on("delete", onDataDelete) socket.on("delete", onDataDelete)
} }
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_announcements, config.NSCLIENT) || if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_announcements, config.NSCLIENT) ||
sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_alarms, config.NSCLIENT) sp.getBoolean(app.aaps.core.utils.R.string.key_ns_alarms, config.NSCLIENT)
) )
alarmSocket = IO.socket(urlAlarm).also { socket -> alarmSocket = IO.socket(urlAlarm).also { socket ->
socket.on(Socket.EVENT_CONNECT, onConnectAlarms) socket.on(Socket.EVENT_CONNECT, onConnectAlarms)
@ -525,7 +525,7 @@ class NSClientV3Plugin @Inject constructor(
val data = args[0] as JSONObject val data = args[0] as JSONObject
rxBus.send(EventNSClientNewLog("◄ ANNOUNCEMENT", data.optString("message"))) rxBus.send(EventNSClientNewLog("◄ ANNOUNCEMENT", data.optString("message")))
aapsLogger.debug(LTag.NSCLIENT, data.toString()) aapsLogger.debug(LTag.NSCLIENT, data.toString())
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_announcements, config.NSCLIENT)) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_announcements, config.NSCLIENT))
uiInteraction.addNotificationWithAction(injector, NSAlarmObject(data)) uiInteraction.addNotificationWithAction(injector, NSAlarmObject(data))
} }
private val onAlarm = Emitter.Listener { args -> private val onAlarm = Emitter.Listener { args ->
@ -546,8 +546,8 @@ class NSClientV3Plugin @Inject constructor(
val data = args[0] as JSONObject val data = args[0] as JSONObject
rxBus.send(EventNSClientNewLog("◄ ALARM", data.optString("message"))) rxBus.send(EventNSClientNewLog("◄ ALARM", data.optString("message")))
aapsLogger.debug(LTag.NSCLIENT, data.toString()) aapsLogger.debug(LTag.NSCLIENT, data.toString())
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_alarms, config.NSCLIENT)) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_alarms, config.NSCLIENT)) {
val snoozedTo = sp.getLong(rh.gs(info.nightscout.core.utils.R.string.key_snoozed_to) + data.optString("level"), 0L) val snoozedTo = sp.getLong(rh.gs(app.aaps.core.utils.R.string.key_snoozed_to) + data.optString("level"), 0L)
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo)
uiInteraction.addNotificationWithAction(injector, NSAlarmObject(data)) uiInteraction.addNotificationWithAction(injector, NSAlarmObject(data))
} }
@ -557,8 +557,8 @@ class NSClientV3Plugin @Inject constructor(
val data = args[0] as JSONObject val data = args[0] as JSONObject
rxBus.send(EventNSClientNewLog("◄ URGENT ALARM", data.optString("message"))) rxBus.send(EventNSClientNewLog("◄ URGENT ALARM", data.optString("message")))
aapsLogger.debug(LTag.NSCLIENT, data.toString()) aapsLogger.debug(LTag.NSCLIENT, data.toString())
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_alarms, config.NSCLIENT)) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_alarms, config.NSCLIENT)) {
val snoozedTo = sp.getLong(rh.gs(info.nightscout.core.utils.R.string.key_snoozed_to) + data.optString("level"), 0L) val snoozedTo = sp.getLong(rh.gs(app.aaps.core.utils.R.string.key_snoozed_to) + data.optString("level"), 0L)
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo)
uiInteraction.addNotificationWithAction(injector, NSAlarmObject(data)) uiInteraction.addNotificationWithAction(injector, NSAlarmObject(data))
} }
@ -599,7 +599,7 @@ class NSClientV3Plugin @Inject constructor(
// If WS is enabled, download is triggered by changes in NS. Thus uploadOnly // If WS is enabled, download is triggered by changes in NS. Thus uploadOnly
// Exception is after reset to full sync (initialLoadFinished == false), where // Exception is after reset to full sync (initialLoadFinished == false), where
// older data must be loaded directly and then continue over WS // older data must be loaded directly and then continue over WS
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_use_ws, true) && initialLoadFinished) if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_use_ws, true) && initialLoadFinished)
executeUpload("START $reason", forceNew = true) executeUpload("START $reason", forceNew = true)
else else
executeLoop("START $reason", forceNew = true) executeLoop("START $reason", forceNew = true)
@ -612,7 +612,7 @@ class NSClientV3Plugin @Inject constructor(
override fun detectedNsVersion(): String? = nsAndroidClient?.lastStatus?.version override fun detectedNsVersion(): String? = nsAndroidClient?.lastStatus?.version
override val address: String get() = sp.getString(info.nightscout.core.utils.R.string.key_nsclientinternal_url, "") override val address: String get() = sp.getString(app.aaps.core.utils.R.string.key_nsclientinternal_url, "")
override fun isFirstLoad(collection: NsClient.Collection) = override fun isFirstLoad(collection: NsClient.Collection) =
when (collection) { when (collection) {
@ -695,7 +695,7 @@ class NSClientV3Plugin @Inject constructor(
result.identifier?.let { result.identifier?.let {
dataPair.value.interfaceIDs.nightscoutId = it dataPair.value.interfaceIDs.nightscoutId = it
storeDataForDb.nsIdDeviceStatuses.add(dataPair.value) storeDataForDb.nsIdDeviceStatuses.add(dataPair.value)
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectives_pump_status_is_available_in_ns, true) sp.putBoolean(app.aaps.core.utils.R.string.key_objectives_pump_status_is_available_in_ns, true)
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
@ -931,7 +931,7 @@ class NSClientV3Plugin @Inject constructor(
} }
private fun executeLoop(origin: String, forceNew: Boolean) { private fun executeLoop(origin: String, forceNew: Boolean) {
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_use_ws, true) && initialLoadFinished) return if (sp.getBoolean(app.aaps.core.utils.R.string.key_ns_use_ws, true) && initialLoadFinished) return
if (sp.getBoolean(R.string.key_ns_paused, false)) { if (sp.getBoolean(R.string.key_ns_paused, false)) {
rxBus.send(EventNSClientNewLog("● RUN", "paused $origin")) rxBus.send(EventNSClientNewLog("● RUN", "paused $origin"))
return return

View file

@ -34,7 +34,7 @@ class LoadBgWorker(
@Inject lateinit var storeDataForDb: StoreDataForDb @Inject lateinit var storeDataForDb: StoreDataForDb
override suspend fun doWorkAndLog(): Result { override suspend fun doWorkAndLog(): Result {
if (!nsClientSource.isEnabled() && !sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_cgm, false)) if (!nsClientSource.isEnabled() && !sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_cgm, false))
return Result.success(workDataOf("Result" to "Load not enabled")) return Result.success(workDataOf("Result" to "Load not enabled"))
val nsAndroidClient = nsClientV3Plugin.nsAndroidClient ?: return Result.failure(workDataOf("Error" to "AndroidClient is null")) val nsAndroidClient = nsClientV3Plugin.nsAndroidClient ?: return Result.failure(workDataOf("Error" to "AndroidClient is null"))
@ -62,7 +62,7 @@ class LoadBgWorker(
val action = if (isFirstLoad) "RCV-F" else "RCV" val action = if (isFirstLoad) "RCV-F" else "RCV"
rxBus.send(EventNSClientNewLog("$action", "${sgvs.size} SVGs from ${dateUtil.dateAndTimeAndSecondsString(lastLoaded)}")) rxBus.send(EventNSClientNewLog("$action", "${sgvs.size} SVGs from ${dateUtil.dateAndTimeAndSecondsString(lastLoaded)}"))
// Objective0 // Objective0
sp.putBoolean(info.nightscout.core.utils.R.string.key_objectives_bg_is_available_in_ns, true) sp.putBoolean(app.aaps.core.utils.R.string.key_objectives_bg_is_available_in_ns, true)
// Schedule processing of fetched data and continue of loading // Schedule processing of fetched data and continue of loading
continueLoading = response.code != 304 continueLoading = response.code != 304
nsIncomingDataProcessor.processSgvs(sgvs) nsIncomingDataProcessor.processSgvs(sgvs)

View file

@ -61,7 +61,7 @@ class DataSyncSelectorXdripImpl @Inject constructor(
} }
private val queueCounter = QueueCounter() private val queueCounter = QueueCounter()
private val isEnabled get() = sp.getBoolean(info.nightscout.core.utils.R.string.key_xdrip_local_broadcasts, false) private val isEnabled get() = sp.getBoolean(app.aaps.core.utils.R.string.key_xdrip_local_broadcasts, false)
private val xdripPlugin get() = xdripBroadcast.get() private val xdripPlugin get() = xdripBroadcast.get()
private val maxAge get() = T.days(1).msecs() private val maxAge get() = T.days(1).msecs()
@ -538,7 +538,7 @@ class DataSyncSelectorXdripImpl @Inject constructor(
private fun processChangedProfileStore() { private fun processChangedProfileStore() {
if (!isEnabled) return if (!isEnabled) return
val lastSync = sp.getLong(R.string.key_xdrip_profile_store_last_synced_timestamp, 0) val lastSync = sp.getLong(R.string.key_xdrip_profile_store_last_synced_timestamp, 0)
val lastChange = sp.getLong(info.nightscout.core.utils.R.string.key_local_profile_last_change, 0) val lastChange = sp.getLong(app.aaps.core.utils.R.string.key_local_profile_last_change, 0)
if (lastChange == 0L) return if (lastChange == 0L) return
if (lastChange > lastSync) { if (lastChange > lastSync) {
if (activePlugin.activeProfileSource.profile?.allProfilesValid != true) return if (activePlugin.activeProfileSource.profile?.allProfilesValid != true) return

View file

@ -288,7 +288,7 @@ class XdripPlugin @Inject constructor(
// sent in 640G mode // sent in 640G mode
// com.eveningoutpost.dexdrip.NSEmulatorReceiver // com.eveningoutpost.dexdrip.NSEmulatorReceiver
override fun sendIn640gMode(glucoseValue: GlucoseValue) { override fun sendIn640gMode(glucoseValue: GlucoseValue) {
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_dexcomg5_xdripupload, false)) { if (sp.getBoolean(app.aaps.core.utils.R.string.key_dexcomg5_xdripupload, false)) {
val format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US) val format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US)
try { try {
val entriesBody = JSONArray() val entriesBody = JSONArray()

View file

@ -22,7 +22,6 @@ import app.aaps.core.nssdk.remotemodel.LastModified
import app.aaps.core.utils.receivers.DataWorkerStorage import app.aaps.core.utils.receivers.DataWorkerStorage
import app.aaps.database.entities.GlucoseValue import app.aaps.database.entities.GlucoseValue
import app.aaps.database.entities.embedments.InterfaceIDs import app.aaps.database.entities.embedments.InterfaceIDs
import app.aaps.database.impl.AppRepository
import app.aaps.implementation.utils.DecimalFormatterImpl import app.aaps.implementation.utils.DecimalFormatterImpl
import app.aaps.plugins.sync.nsShared.NsIncomingDataProcessor import app.aaps.plugins.sync.nsShared.NsIncomingDataProcessor
import app.aaps.plugins.sync.nsclient.ReceiverDelegate import app.aaps.plugins.sync.nsclient.ReceiverDelegate
@ -120,7 +119,7 @@ internal class LoadBgWorkerTest : TestBase() {
fun notEnabledNSClientSource() = runTest { fun notEnabledNSClientSource() = runTest {
sut = TestListenableWorkerBuilder<LoadBgWorker>(context).build() sut = TestListenableWorkerBuilder<LoadBgWorker>(context).build()
Mockito.`when`(nsClientSource.isEnabled()).thenReturn(false) Mockito.`when`(nsClientSource.isEnabled()).thenReturn(false)
Mockito.`when`(sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_cgm, false)).thenReturn(false) Mockito.`when`(sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_cgm, false)).thenReturn(false)
val result = sut.doWorkAndLog() val result = sut.doWorkAndLog()
assertIs<ListenableWorker.Result.Success>(result) assertIs<ListenableWorker.Result.Success>(result)

View file

@ -82,7 +82,7 @@ class DanaRKoreanPlugin @Inject constructor(
init { init {
pluginDescription.description(info.nightscout.pump.dana.R.string.description_pump_dana_r_korean) pluginDescription.description(info.nightscout.pump.dana.R.string.description_pump_dana_r_korean)
useExtendedBoluses = sp.getBoolean(info.nightscout.core.utils.R.string.key_danar_useextended, false) useExtendedBoluses = sp.getBoolean(app.aaps.core.utils.R.string.key_danar_useextended, false)
pumpDescription.fillFor(PumpType.DANA_R_KOREAN) pumpDescription.fillFor(PumpType.DANA_R_KOREAN)
} }
@ -94,7 +94,7 @@ class DanaRKoreanPlugin @Inject constructor(
.subscribe({ .subscribe({
if (isEnabled()) { if (isEnabled()) {
val previousValue = useExtendedBoluses val previousValue = useExtendedBoluses
useExtendedBoluses = sp.getBoolean(info.nightscout.core.utils.R.string.key_danar_useextended, false) useExtendedBoluses = sp.getBoolean(app.aaps.core.utils.R.string.key_danar_useextended, false)
if (useExtendedBoluses != previousValue && pumpSync.expectedPumpState().extendedBolus != null) { if (useExtendedBoluses != previousValue && pumpSync.expectedPumpState().extendedBolus != null) {
sExecutionService.extendedBolusStop() sExecutionService.extendedBolusStop()
} }

View file

@ -87,7 +87,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
this.rh = rh; this.rh = rh;
this.fabricPrivacy = fabricPrivacy; this.fabricPrivacy = fabricPrivacy;
useExtendedBoluses = sp.getBoolean(info.nightscout.core.utils.R.string.key_danar_useextended, false); useExtendedBoluses = sp.getBoolean(app.aaps.core.utils.R.string.key_danar_useextended, false);
pumpDescription.fillFor(PumpType.DANA_R); pumpDescription.fillFor(PumpType.DANA_R);
} }
@ -101,7 +101,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
.subscribe(event -> { .subscribe(event -> {
if (isEnabled()) { if (isEnabled()) {
boolean previousValue = useExtendedBoluses; boolean previousValue = useExtendedBoluses;
useExtendedBoluses = sp.getBoolean(info.nightscout.core.utils.R.string.key_danar_useextended, false); useExtendedBoluses = sp.getBoolean(app.aaps.core.utils.R.string.key_danar_useextended, false);
if (useExtendedBoluses != previousValue && pumpSync.expectedPumpState().getExtendedBolus() != null) { if (useExtendedBoluses != previousValue && pumpSync.expectedPumpState().getExtendedBolus() != null) {
sExecutionService.extendedBolusStop(); sExecutionService.extendedBolusStop();

View file

@ -767,7 +767,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
private fun getPumpUnreachableTimeout(): Duration { private fun getPumpUnreachableTimeout(): Duration {
return Duration.ofMinutes( return Duration.ofMinutes(
sp.getInt( sp.getInt(
info.nightscout.core.utils.R.string.key_pump_unreachable_threshold_minutes, app.aaps.core.utils.R.string.key_pump_unreachable_threshold_minutes,
Constants.DEFAULT_PUMP_UNREACHABLE_THRESHOLD_MINUTES Constants.DEFAULT_PUMP_UNREACHABLE_THRESHOLD_MINUTES
).toLong() ).toLong()
) )

View file

@ -703,7 +703,7 @@ class OmnipodErosOverviewFragment : DaggerFragment() {
// FIXME ideally we should just have access to LocalAlertUtils here // FIXME ideally we should just have access to LocalAlertUtils here
private fun getPumpUnreachableTimeout(): Duration { private fun getPumpUnreachableTimeout(): Duration {
return Duration.standardMinutes(sp.getInt(info.nightscout.core.utils.R.string.key_pump_unreachable_threshold_minutes, Constants.DEFAULT_PUMP_UNREACHABLE_THRESHOLD_MINUTES).toLong()) return Duration.standardMinutes(sp.getInt(app.aaps.core.utils.R.string.key_pump_unreachable_threshold_minutes, Constants.DEFAULT_PUMP_UNREACHABLE_THRESHOLD_MINUTES).toLong())
} }
inner class DisplayResultDialogCallback(private val errorMessagePrefix: String, private val withSoundOnError: Boolean) : Callback() { inner class DisplayResultDialogCallback(private val errorMessagePrefix: String, private val withSoundOnError: Boolean) : Callback() {

View file

@ -116,7 +116,7 @@ open class VirtualPumpPlugin @Inject constructor(
disposable += rxBus disposable += rxBus
.toObservable(EventPreferenceChange::class.java) .toObservable(EventPreferenceChange::class.java)
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribe({ event: EventPreferenceChange -> if (event.isChanged(rh.gs(info.nightscout.core.utils.R.string.key_virtualpump_type))) refreshConfiguration() }, fabricPrivacy::logException) .subscribe({ event: EventPreferenceChange -> if (event.isChanged(rh.gs(app.aaps.core.utils.R.string.key_virtualpump_type))) refreshConfiguration() }, fabricPrivacy::logException)
refreshConfiguration() refreshConfiguration()
} }
@ -127,7 +127,7 @@ open class VirtualPumpPlugin @Inject constructor(
override fun preprocessPreferences(preferenceFragment: PreferenceFragmentCompat) { override fun preprocessPreferences(preferenceFragment: PreferenceFragmentCompat) {
super.preprocessPreferences(preferenceFragment) super.preprocessPreferences(preferenceFragment)
val uploadStatus = preferenceFragment.findPreference(rh.gs(info.nightscout.core.utils.R.string.key_virtual_pump_upload_status)) as SwitchPreference? val uploadStatus = preferenceFragment.findPreference(rh.gs(app.aaps.core.utils.R.string.key_virtual_pump_upload_status)) as SwitchPreference?
?: return ?: return
uploadStatus.isVisible = !config.NSCLIENT uploadStatus.isVisible = !config.NSCLIENT
} }
@ -341,7 +341,7 @@ open class VirtualPumpPlugin @Inject constructor(
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject { override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject {
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
if (!sp.getBoolean(info.nightscout.core.utils.R.string.key_virtual_pump_upload_status, false)) { if (!sp.getBoolean(app.aaps.core.utils.R.string.key_virtual_pump_upload_status, false)) {
return JSONObject() return JSONObject()
} }
val pump = JSONObject() val pump = JSONObject()
@ -391,7 +391,7 @@ open class VirtualPumpPlugin @Inject constructor(
override fun canHandleDST(): Boolean = true override fun canHandleDST(): Boolean = true
fun refreshConfiguration() { fun refreshConfiguration() {
val pumpType = sp.getString(info.nightscout.core.utils.R.string.key_virtualpump_type, PumpType.GENERIC_AAPS.description) val pumpType = sp.getString(app.aaps.core.utils.R.string.key_virtualpump_type, PumpType.GENERIC_AAPS.description)
val pumpTypeNew = PumpType.getByDescription(pumpType) val pumpTypeNew = PumpType.getByDescription(pumpType)
aapsLogger.debug(LTag.PUMP, "Pump in configuration: $pumpType, PumpType object: $pumpTypeNew") aapsLogger.debug(LTag.PUMP, "Pump in configuration: $pumpType, PumpType object: $pumpTypeNew")
if (this.pumpType == pumpTypeNew) return if (this.pumpType == pumpTypeNew) return

View file

@ -47,16 +47,16 @@ class VirtualPumpPluginUTest : TestBase() {
@Test @Test
fun refreshConfiguration() { fun refreshConfiguration() {
`when`(sp.getString(info.nightscout.core.utils.R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo") `when`(sp.getString(app.aaps.core.utils.R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo")
virtualPumpPlugin.refreshConfiguration() virtualPumpPlugin.refreshConfiguration()
Assertions.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType) Assertions.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType)
} }
@Test @Test
fun refreshConfigurationTwice() { fun refreshConfigurationTwice() {
`when`(sp.getString(info.nightscout.core.utils.R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo") `when`(sp.getString(app.aaps.core.utils.R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo")
virtualPumpPlugin.refreshConfiguration() virtualPumpPlugin.refreshConfiguration()
`when`(sp.getString(info.nightscout.core.utils.R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo") `when`(sp.getString(app.aaps.core.utils.R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo")
virtualPumpPlugin.refreshConfiguration() virtualPumpPlugin.refreshConfiguration()
Assertions.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType) Assertions.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType)
} }

View file

@ -47,12 +47,12 @@ import kotlin.math.min
} }
private fun loadAge(): Int = when (sp.getString(info.nightscout.core.utils.R.string.key_age, "")) { private fun loadAge(): Int = when (sp.getString(app.aaps.core.utils.R.string.key_age, "")) {
rh.gs(info.nightscout.core.utils.R.string.key_child) -> CHILD rh.gs(app.aaps.core.utils.R.string.key_child) -> CHILD
rh.gs(info.nightscout.core.utils.R.string.key_teenage) -> TEENAGE rh.gs(app.aaps.core.utils.R.string.key_teenage) -> TEENAGE
rh.gs(info.nightscout.core.utils.R.string.key_adult) -> ADULT rh.gs(app.aaps.core.utils.R.string.key_adult) -> ADULT
rh.gs(info.nightscout.core.utils.R.string.key_resistantadult) -> RESISTANT_ADULT rh.gs(app.aaps.core.utils.R.string.key_resistantadult) -> RESISTANT_ADULT
rh.gs(info.nightscout.core.utils.R.string.key_pregnant) -> PREGNANT rh.gs(app.aaps.core.utils.R.string.key_pregnant) -> PREGNANT
else -> ADULT else -> ADULT
} }

Some files were not shown because too many files have changed in this diff Show more