automation module

This commit is contained in:
Milos Kozak 2021-02-22 17:22:30 +01:00
parent c501a41824
commit a0632f7753
224 changed files with 746 additions and 490 deletions

View file

@ -177,6 +177,7 @@ dependencies {
wearApp project(':wear')
implementation project(':core')
implementation project(':automation')
implementation project(':combo')
implementation project(':database')
implementation project(':dana')

View file

@ -140,9 +140,6 @@
android:resource="@xml/filepaths" />
</provider>
<service
android:name=".services.LocationService"
android:exported="false" />
<service
android:name=".plugins.general.wear.wearintegration.WatchUpdaterService"
android:exported="true">

View file

@ -5,6 +5,7 @@ import dagger.Component
import dagger.android.AndroidInjectionModule
import dagger.android.AndroidInjector
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.automation.di.AutomationModule
import info.nightscout.androidaps.combo.di.ComboModule
import info.nightscout.androidaps.core.di.CoreModule
import info.nightscout.androidaps.dana.di.DanaModule

View file

@ -10,13 +10,17 @@ import info.nightscout.androidaps.Config
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.db.DatabaseHelperProvider
import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefs
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
import info.nightscout.androidaps.queue.CommandQueue
import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
import info.nightscout.androidaps.utils.resources.IconsProvider
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.androidaps.utils.rx.DefaultAapsSchedulers
import info.nightscout.androidaps.utils.storage.FileStorage
@ -66,5 +70,9 @@ open class AppModule {
@Binds fun bindUploadQueueInterface(uploadQueue: UploadQueue): UploadQueueInterface
@Binds fun bindNotificationHolderInterface(notificationHolder: NotificationHolder): NotificationHolderInterface
@Binds fun bindImportExportPrefsInterface(importExportPrefs: ImportExportPrefs): ImportExportPrefsInterface
@Binds fun bindIconsProviderInterface(iconsProvider: IconsProvider): IconsProviderInterface
@Binds fun bindLoopInterface(loopPlugin: LoopPlugin): LoopInterface
@Binds fun bindIobCobCalculatorInterface(iobCobCalculatorPlugin: IobCobCalculatorPlugin): IobCobCalculatorInterface
@Binds fun bindSmsCommunicatorInterface(smsCommunicatorPlugin: SmsCommunicatorPlugin): SmsCommunicatorInterface
}
}

View file

@ -28,7 +28,7 @@ import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.FabricPrivacy

View file

@ -24,7 +24,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.overview.OverviewMenus
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensBgLoaded
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DefaultValueHelper

View file

@ -35,7 +35,7 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotifi
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
import info.nightscout.androidaps.plugins.general.wear.events.EventWearDoAction
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
import info.nightscout.androidaps.queue.Callback
@ -58,7 +58,7 @@ import kotlin.math.abs
@Singleton
open class LoopPlugin @Inject constructor(
injector: HasAndroidInjector,
aapsLogger: AAPSLogger?,
aapsLogger: AAPSLogger,
private val aapsSchedulers: AapsSchedulers,
private val rxBus: RxBusWrapper,
private val sp: SP,
@ -85,7 +85,7 @@ open class LoopPlugin @Inject constructor(
.preferencesId(R.xml.pref_loop)
.enableByDefault(config.APS)
.description(R.string.description_loop),
aapsLogger!!, resourceHelper, injector
aapsLogger, resourceHelper, injector
), LoopInterface {
private val disposable = CompositeDisposable()
@ -147,7 +147,7 @@ open class LoopPlugin @Inject constructor(
}
}
fun suspendTo(endTime: Long) {
override fun suspendTo(endTime: Long) {
sp.putLong("loopSuspendedTill", endTime)
sp.putBoolean("isSuperBolus", false)
sp.putBoolean("isDisconnected", false)
@ -178,7 +178,7 @@ open class LoopPlugin @Inject constructor(
}
// time exceeded
val isSuspended: Boolean
override val isSuspended: Boolean
get() {
val loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L)
if (loopSuspendedTill == 0L) return false
@ -638,7 +638,7 @@ open class LoopPlugin @Inject constructor(
createOfflineEvent(durationInMinutes)
}
fun suspendLoop(durationInMinutes: Int) {
override fun suspendLoop(durationInMinutes: Int) {
suspendTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000)
commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() {
@ -650,7 +650,7 @@ open class LoopPlugin @Inject constructor(
createOfflineEvent(durationInMinutes)
}
fun createOfflineEvent(durationInMinutes: Int) {
override fun createOfflineEvent(durationInMinutes: Int) {
val data = JSONObject()
try {
data.put("eventType", CareportalEvent.OPENAPSOFFLINE)

View file

@ -23,7 +23,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.receivers.ReceiverStatusStore
import info.nightscout.androidaps.services.Intents
import info.nightscout.androidaps.utils.DefaultValueHelper

View file

@ -46,7 +46,7 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific
import info.nightscout.androidaps.plugins.general.wear.events.EventWearDoAction
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.plugins.source.DexcomPlugin
@ -764,7 +764,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
var cobText: String = resourceHelper.gs(R.string.value_unavailable_short)
val cobInfo = iobCobCalculatorPlugin.getCobInfo(false, "Overview COB")
if (cobInfo.displayCob != null) {
cobText = resourceHelper.gs(R.string.format_carbs, cobInfo.displayCob.toInt())
cobText = resourceHelper.gs(R.string.format_carbs, cobInfo.displayCob!!.toInt())
if (cobInfo.futureCarbs > 0) cobText += "(" + DecimalFormatter.to0Decimal(cobInfo.futureCarbs) + ")"
}

View file

@ -14,13 +14,13 @@ import androidx.core.app.NotificationCompat
import androidx.recyclerview.widget.RecyclerView
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.OverviewNotificationItemBinding
import info.nightscout.androidaps.interfaces.NotificationHolderInterface
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
import info.nightscout.androidaps.services.AlarmSoundServiceHelper
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.androidNotification.openAppIntent
import info.nightscout.androidaps.utils.resources.IconsProvider
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
@ -37,7 +37,8 @@ class NotificationStore @Inject constructor(
private val context: Context,
private val iconsProvider: IconsProvider,
private val alarmSoundServiceHelper: AlarmSoundServiceHelper,
private val dateUtil: DateUtil
private val dateUtil: DateUtil,
private val notificationHolder: NotificationHolderInterface
) {
private var store: MutableList<Notification> = ArrayList()
@ -112,7 +113,7 @@ class NotificationStore @Inject constructor(
.setStyle(NotificationCompat.BigTextStyle().bigText(n.text))
.setPriority(NotificationCompat.PRIORITY_MAX)
.setDeleteIntent(deleteIntent(n.id))
.setContentIntent(openAppIntent(context))
.setContentIntent(notificationHolder.openAppIntent(context))
if (n.level == Notification.URGENT) {
notificationBuilder.setVibrate(longArrayOf(1000, 1000, 1000, 1000))
.setContentTitle(resourceHelper.gs(R.string.urgent_alarm))

View file

@ -12,6 +12,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import javax.inject.Inject
@Suppress("SpellCheckingInspection")
class NotificationWithAction constructor(
injector: HasAndroidInjector
) : Notification() {

View file

@ -17,11 +17,8 @@ import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
import info.nightscout.androidaps.utils.androidNotification.openAppIntent
import info.nightscout.androidaps.utils.resources.IconsProvider
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers
@ -43,10 +40,9 @@ class PersistentNotificationPlugin @Inject constructor(
private val iobCobCalculatorPlugin: IobCobCalculatorPlugin,
private val rxBus: RxBusWrapper,
private val context: Context,
private val notificationHolder: NotificationHolder,
private val notificationHolder: NotificationHolderInterface,
private val dummyServiceHelper: DummyServiceHelper,
private val iconsProvider: IconsProvider,
private val databaseHelper: DatabaseHelperInterface
private val iconsProvider: IconsProvider
) : PluginBase(PluginDescription()
.mainType(PluginType.GENERAL)
.neverVisible(true)
@ -216,7 +212,7 @@ class PersistentNotificationPlugin @Inject constructor(
.setUnreadConversation(unreadConversationBuilder.build()))
}
/// End Android Auto
builder.setContentIntent(openAppIntent(context))
builder.setContentIntent(notificationHolder.openAppIntent(context))
val mNotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val notification = builder.build()
mNotificationManager.notify(notificationHolder.notificationID, notification)

View file

@ -80,7 +80,7 @@ class SmsCommunicatorPlugin @Inject constructor(
.preferencesId(R.xml.pref_smscommunicator)
.description(R.string.description_sms_communicator),
aapsLogger, resourceHelper, injector
) {
), SmsCommunicatorInterface {
private val disposable = CompositeDisposable()
var allowedNumbers: MutableList<String> = ArrayList()
@ -998,7 +998,7 @@ class SmsCommunicatorPlugin @Inject constructor(
} else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
}
fun sendNotificationToAllNumbers(text: String): Boolean {
override fun sendNotificationToAllNumbers(text: String): Boolean {
var result = true
for (i in allowedNumbers.indices) {
val sms = Sms(allowedNumbers[i], text)

View file

@ -204,7 +204,7 @@ class ActionStringHandler @Inject constructor(
val format = DecimalFormat("0.00")
val formatInt = DecimalFormat("0")
val bolusWizard = BolusWizard(injector).doCalc(profile, profileName, activePlugin.activeTreatments.tempTargetFromHistory,
carbsAfterConstraints, cobInfo.displayCob, bgReading.valueToUnits(profileFunction.getUnits()),
carbsAfterConstraints, if (cobInfo.displayCob != null) cobInfo.displayCob!! else 0.0, bgReading.valueToUnits(profileFunction.getUnits()),
0.0, percentage.toDouble(), useBG, useCOB, useBolusIOB, useBasalIOB, false, useTT, useTrend, false)
if (Math.abs(bolusWizard.insulinAfterConstraints - bolusWizard.calculatedTotalInsulin) >= 0.01) {
sendError("Insulin constraint violation!" +

View file

@ -16,7 +16,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
import info.nightscout.androidaps.plugins.general.wear.wearintegration.WatchUpdaterService
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers

View file

@ -16,7 +16,7 @@ import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.FabricPrivacy
import io.reactivex.rxkotlin.plusAssign

View file

@ -71,14 +71,14 @@ open class IobCobCalculatorPlugin @Inject constructor(
private var absIobTable = LongSparseArray<IobTotal?>() // oldest at index 0, absolute insulin in the body
private var autosensDataTable = LongSparseArray<AutosensData>() // oldest at index 0
private var basalDataTable = LongSparseArray<BasalData>() // oldest at index 0
@Volatile var bgReadings: List<GlucoseValue> = listOf() // newest at index 0
@Volatile override var bgReadings: List<GlucoseValue> = listOf() // newest at index 0
@Volatile var bucketedData: MutableList<InMemoryGlucoseValue>? = null
// we need to make sure that bucketed_data will always have the same timestamp for correct use of cached values
// once referenceTime != null all bucketed data should be (x * 5min) from referenceTime
var referenceTime: Long = -1
private var lastUsed5minCalculation: Boolean? = null // true if used 5min bucketed data
val dataLock = Any()
override val dataLock = Any()
var stopCalculationTrigger = false
private var thread: Thread? = null
@ -388,7 +388,7 @@ open class IobCobCalculatorPlugin @Inject constructor(
return getBGDataFrom
}
fun calculateFromTreatmentsAndTempsSynchronized(time: Long, profile: Profile?): IobTotal {
override fun calculateFromTreatmentsAndTempsSynchronized(time: Long, profile: Profile?): IobTotal {
synchronized(dataLock) { return calculateFromTreatmentsAndTemps(time, profile) }
}
@ -524,7 +524,7 @@ open class IobCobCalculatorPlugin @Inject constructor(
synchronized(dataLock) { return getLastAutosensData(reason) }
}
fun getCobInfo(_synchronized: Boolean, reason: String): CobInfo {
override fun getCobInfo(_synchronized: Boolean, reason: String): CobInfo {
val autosensData = if (_synchronized) getLastAutosensDataSynchronized(reason) else getLastAutosensData(reason)
var displayCob: Double? = null
var futureCarbs = 0.0
@ -563,7 +563,7 @@ open class IobCobCalculatorPlugin @Inject constructor(
return sum / count
}
fun getLastAutosensData(reason: String): AutosensData? {
override fun getLastAutosensData(reason: String): AutosensData? {
if (autosensDataTable.size() < 1) {
aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA null: autosensDataTable empty ($reason)")
return null

View file

@ -17,7 +17,7 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin.Companion.roundUpTime
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensBgLoaded
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
@ -82,7 +82,7 @@ class IobCobOref1Thread internal constructor(
rxBus.send(EventAutosensBgLoaded(cause))
}
val bucketedData = iobCobCalculatorPlugin.bucketedData
val autosensDataTable = iobCobCalculatorPlugin.autosensDataTable
val autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable()
if (bucketedData == null || bucketedData.size < 3) {
aapsLogger.debug(LTag.AUTOSENS, "Aborting calculation thread (No bucketed data available): $from")
return
@ -288,7 +288,7 @@ class IobCobOref1Thread internal constructor(
}
}
// add an extra negative deviation if a high temptarget is running and exercise mode is set
// add an extra negative deviation if a high temp target is running and exercise mode is set
// TODO AS-FIX
@Suppress("SimplifyBooleanWithConstants")
if (false && sp.getBoolean(R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity)) {

View file

@ -18,7 +18,7 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin.Companion.roundUpTime
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensBgLoaded
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
@ -83,7 +83,7 @@ class IobCobThread @Inject internal constructor(
rxBus.send(EventAutosensBgLoaded(cause))
}
val bucketedData = iobCobCalculatorPlugin.bucketedData
val autosensDataTable = iobCobCalculatorPlugin.autosensDataTable
val autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable()
if (bucketedData == null || bucketedData.size < 3) {
aapsLogger.debug(LTag.AUTOSENS, "Aborting calculation thread (No bucketed data available): $from")
return

View file

@ -21,7 +21,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsBolusFragment.RecyclerViewAdapter.TreatmentsViewHolder
import info.nightscout.androidaps.utils.DateUtil

View file

@ -24,7 +24,7 @@ import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsExtendedBolusesFragment.RecyclerViewAdapter.ExtendedBolusesViewHolder
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy

View file

@ -22,7 +22,7 @@ import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsTemporaryBasalsFragment.RecyclerViewAdapter.TempBasalsViewHolder
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy

View file

@ -2,11 +2,15 @@ package info.nightscout.androidaps.utils.androidNotification
import android.app.Notification
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import androidx.core.app.NotificationCompat
import info.nightscout.androidaps.R
import androidx.core.app.TaskStackBuilder
import info.nightscout.androidaps.MainActivity
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.interfaces.IconsProviderInterface
import info.nightscout.androidaps.interfaces.NotificationHolderInterface
import info.nightscout.androidaps.utils.resources.IconsProvider
import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject
import javax.inject.Singleton
@ -15,7 +19,7 @@ import javax.inject.Singleton
class NotificationHolder @Inject constructor(
resourceHelper: ResourceHelper,
context: Context,
iconsProvider: IconsProvider
iconsProvider: IconsProviderInterface
) : NotificationHolderInterface {
override val channelID = "AndroidAPS-Ongoing"
@ -32,4 +36,10 @@ class NotificationHolder @Inject constructor(
.also {
(context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).notify(notificationID, it)
}
override fun openAppIntent(context: Context): PendingIntent? = TaskStackBuilder.create(context).run {
addParentStack(MainActivity::class.java)
addNextIntent(Intent(context, MainActivity::class.java))
getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)
}
}

View file

@ -1,13 +0,0 @@
package info.nightscout.androidaps.utils.androidNotification
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import androidx.core.app.TaskStackBuilder
import info.nightscout.androidaps.MainActivity
fun openAppIntent(context: Context): PendingIntent? = TaskStackBuilder.create(context).run {
addParentStack(MainActivity::class.java)
addNextIntent(Intent(context, MainActivity::class.java))
getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)
}

View file

@ -1,21 +1,22 @@
package info.nightscout.androidaps.utils.resources
import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.ConfigInterface
import info.nightscout.androidaps.interfaces.IconsProviderInterface
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class IconsProvider @Inject constructor(private val config: Config) {
class IconsProvider @Inject constructor(private val config: ConfigInterface) : IconsProviderInterface {
fun getIcon(): Int =
override fun getIcon(): Int =
when {
config.NSCLIENT -> R.mipmap.ic_yellowowl
config.PUMPCONTROL -> R.mipmap.ic_pumpcontrol
else -> R.mipmap.ic_launcher
}
fun getNotificationIcon(): Int =
override fun getNotificationIcon(): Int =
when {
config.NSCLIENT -> R.drawable.ic_notif_nsclient
config.PUMPCONTROL -> R.drawable.ic_notif_pumpcontrol

View file

@ -83,7 +83,7 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec
var cob = 0.0
if (useCOB() == YES) {
val cobInfo = iobCobCalculatorPlugin.getCobInfo(_synchronized, "QuickWizard COB")
if (cobInfo.displayCob != null) cob = cobInfo.displayCob
if (cobInfo.displayCob != null) cob = cobInfo.displayCob!!
}
// Bolus IOB
var bolusIOB = false

View file

@ -699,7 +699,6 @@
<string name="thirdcarbsincrement">Terzo incremento di CHO</string>
<string name="cgm">CGM</string>
<string name="ns_wifionly">Usa solo connessione WiFi</string>
<string name="ns_wifi_ssids">WiFi SSID</string>
<string name="ns_chargingonly">Solo se in carica</string>
<string name="connectionsettings_title">Impostazioni connessione</string>
<string name="ns_wifi_allowedssids">SSID ammessi (separati da punto e virgola)</string>

View file

@ -78,7 +78,6 @@ Eversense-appen.</string>
<string name="openapsma_noglucosedata">Ingen BG-data tillänglig</string>
<string name="openapsma_request_label">Beräknat behov</string>
<string name="glucose">Glukos</string>
<string name="delta">Delta</string>
<string name="sms_delta">Delta:</string>
<string name="configbuilder">Konfigurationsverktyg</string>
<string name="overview">Översikt</string>

View file

@ -87,18 +87,6 @@
<item>@string/key_pregnant</item>
</string-array>
<string-array name="location">
<item>@string/use_passive_location</item>
<item>@string/use_network_location</item>
<item>@string/use_gps_location</item>
</string-array>
<string-array name="locationValues" translatable="false">
<item>PASSIVE</item>
<item>NETWORK</item>
<item>GPS</item>
</string-array>
<string-array name="virtualPumpTypes">
<item>Generic AAPS</item>
<item>Accu-Chek Spirit</item>

View file

@ -26,7 +26,6 @@
<color name="defaulttextcolor">#B3FFFFFF</color>
<color name="tempTargetBackground">#77dd77</color>
<color name="tempTargetConfirmation">#77dd77</color>
<color name="exercise">#67DFE8</color>
@ -51,18 +50,11 @@
<color name="notificationLow">#ff827c</color>
<color name="notificationInfo">#009705</color>
<color name="black_overlay">#66000000</color>
<color name="deviationgrey">#c8666666</color>
<color name="deviationgreen">#7200FF00</color>
<color name="deviationred">#72FF0000</color>
<color name="deviationblack">#72000000</color>
<color name="ribbonDefault">#5a595b</color>
<color name="ribbonWarning">#f4d700</color>
<color name="ribbonCritical">#ff0400</color>
<color name="ribbonTextDefault">#FFFFFF</color>
<color name="ribbonTextWarning">#303030</color>
<color name="splashBackground">#2E2E2E</color>
</resources>

View file

@ -102,7 +102,6 @@
<string name="result_insulin_carbs">Result: %1$s %2$s</string>
<string name="openapsma_noglucosedata">No glucose data available</string>
<string name="openapsma_request_label">Request</string>
<string name="glucose">Glucose</string>
<string name="delta">Delta</string>
<string name="sms_delta">Delta:</string>
@ -155,8 +154,6 @@
<string name="openloop">Open Loop</string>
<string name="lowglucosesuspend">Low Glucose Suspend</string>
<string name="disabledloop">Loop Disabled</string>
<string name="disableloop">Disable loop</string>
<string name="enableloop">Enable loop</string>
<string name="openloop_newsuggestion">New suggestion available</string>
<string name="carbssuggestion">Carbs Suggestion</string>
@ -170,11 +167,8 @@
<string name="careportal_newnstreatment_sensor">Sensor</string>
<string name="careportal_newnstreatment_carbtime_label">Carb time</string>
<string name="careportal_newnstreatment_duration_label">Duration</string>
<string name="careportal_newnstreatment_notes_label">Notes</string>
<string name="event_time_label">Event time</string>
<string name="careportal_newnstreatment_profile_label">Profile</string>
<string name="careportal_newnstreatment_glucosetype">Glucose type</string>
<string name="noprofile">No profile loaded from NS yet</string>
<string name="overview_tempbasal_button">TempBasal</string>
<string name="overview_extendedbolus_button">Extended Bolus</string>
<string name="configbuilder_nightscoutversion_label">Nightscout version:</string>
@ -239,7 +233,6 @@
<string name="smscommunicator_remotecommandsallowed">Allow remote commands via SMS</string>
<string name="smscommunicator_loophasbeendisabled">Loop has been disabled</string>
<string name="smscommunicator_loophasbeenenabled">Loop has been enabled</string>
<string name="smscommunicator_loopisdisabled">Loop is disabled</string>
<string name="smscommunicator_loopisenabled">Loop is enabled</string>
<string name="valuelimitedto">%1$.2f limited to %2$.2f</string>
<string name="valueoutofrange">Value %1$s is out of hard limits</string>
@ -281,7 +274,6 @@
<string name="overview_editquickwizard_valid">Valid:</string>
<string name="overview_editquickwizardlistactivity_add">Add</string>
<string name="overview_quickwizard_item_edit_button">Edit</string>
<string name="overview_quickwizard_item_remove_button">Remove</string>
<string name="mealbolus">Meal</string>
<string name="correctionbous">Corr</string>
<string name="actions">Actions</string>
@ -315,8 +307,6 @@
<string name="sms_minago">%1$dmin ago</string>
<string name="localprofile">Local Profile</string>
<string name="openapsama">OpenAPS AMA</string>
<string name="short_avgdelta">Short avg. delta</string>
<string name="long_avgdelta">Long avg. delta</string>
<string name="array_of_elements">Array of %1$d elements.\nActual value:</string>
<string name="openapsma_autosensdata_label">Autosens data</string>
<string name="openapsma_scriptdebugdata_label">Script debug</string>
@ -326,7 +316,6 @@
<string name="eatingsoon">Eating Soon</string>
<string name="hypo">Hypo</string>
<string name="activity">Activity</string>
<string name="removerecord">Remove record</string>
<string name="actions_shortname">ACT</string>
<string name="configbuilder_shortname">CONF</string>
<string name="loop_shortname">LOOP</string>
@ -345,9 +334,7 @@
<string name="profile">Profile</string>
<string name="openapsama_max_daily_safety_multiplier_summary">Default value: 3 This is a key OpenAPS safety cap. What this does is limit your basals to be 3x (in this people) your biggest basal rate. You likely will not need to change this, but you should be aware thats what is discussed about “3x max daily; 4x current” for safety caps.</string>
<string name="openapsama_current_basal_safety_multiplier_summary">Default value: 4 This is the other half of the key OpenAPS safety caps, and the other half of “3x max daily; 4x current” of the safety caps. This means your basal, regardless of max basal set on your pump, cannot be any higher than this number times the current level of your basal. This is to prevent people from getting into dangerous territory by setting excessively high max basals before understanding how the algorithm works. Again, the default is 4x; most people will never need to adjust this and are instead more likely to need to adjust other settings if they feel like they are “running into” this safety cap.</string>
<string name="key_openapsama_autosens_max" translatable="false">autosens_max</string>
<string name="openapsama_autosens_max_summary">Default value: 1.2\nThis is a multiplier cap for autosens (and soon autotune) to set a 20%% max limit on how high the autosens ratio can be, which in turn determines how high autosens can adjust basals, how low it can adjust ISF, and how low it can set the BG target.</string>
<string name="key_openapsama_autosens_min" translatable="false">autosens_min</string>
<string name="openapsama_autosens_min_summary">Default value: 0.7\nThe other side of the autosens safety limits, putting a cap on how low autosens can adjust basals, and how high it can adjust ISF and BG targets.</string>
<string name="key_openapsama_autosens_adjusttargets" translatable="false">autosens_adjust_targets</string>
<string name="openapsama_autosens_adjusttargets">Autosens adjust targets, too</string>
@ -419,12 +406,10 @@
<string name="needwhitelisting">%1$s needs battery optimalization whitelisting for proper performance</string>
<string name="loopsuspended">Loop suspended</string>
<string name="loopsuspendedfor">Suspended (%1$d m)</string>
<string name="suspendloop">Suspend loop</string>
<string name="suspendloopfor1h">Suspend loop for 1h</string>
<string name="suspendloopfor2h">Suspend loop for 2h</string>
<string name="suspendloopfor3h">Suspend loop for 3h</string>
<string name="suspendloopfor10h">Suspend loop for 10 h</string>
<string name="suspendloopforXmin">Suspend loop for %1$d min</string>
<string name="disconnectpump">Disconnect pump</string>
<string name="disconnectpumpfor15m">Disconnect pump for 15 min</string>
<string name="disconnectpumpfor30m">Disconnect pump for 30 min</string>
@ -485,8 +470,6 @@
<string name="key_statuslights_bat_critical" translatable="false">statuslights_bat_critical</string>
<string name="statuslights_bat_critical">Threshold critical pump battery level [%]</string>
<string name="prediction_shortname">PRED</string>
<string name="iob">IOB</string>
<string name="cob">COB</string>
<string name="basal_shortname">BAS</string>
<string name="deviation_shortname">DEV</string>
<string name="activity_shortname">ACT</string>
@ -551,7 +534,6 @@
<string name="valuesnotstored">Values not stored!</string>
<string name="ns_localbroadcasts">Enable broadcasts to other apps (like xDrip+). Do not enable if you have more than one instance of AAPS or NSClient installed!</string>
<string name="ns_localbroadcasts_title">Enable local Broadcasts.</string>
<string name="careportal_newnstreatment_duration_min_label">Duration [min]</string>
<string name="openapssmb">OpenAPS SMB</string>
<string name="key_use_smb" translatable="false">use_smb</string>
<string name="key_use_uam" translatable="false">use_uam</string>
@ -739,7 +721,6 @@
<string name="limitingiob">Limiting IOB to %1$.1f U because of %2$s</string>
<string name="maxvalueinpreferences">max value in preferences</string>
<string name="hardlimit">hard limit</string>
<string name="key_treatmentssafety_maxcarbs" translatable="false">treatmentssafety_maxcarbs</string>
<string name="key_openapsama_useautosens" translatable="false">openapsama_useautosens</string>
<string name="readstatusfailed">Read status failed</string>
<string name="record_pump_site_change">Record pump site change</string>
@ -754,8 +735,6 @@
<string name="openapssmb_maxiob_summary">This value is called Max IOB in OpenAPS context\nOpenAPS will not add more insulin if current IOB is greater than this value</string>
<string name="absorption_cutoff_title">Meal max absorption time [h]</string>
<string name="absorption_cutoff_summary">Time at which any meal is considered absorbed. Remaining carbs will be cut off.</string>
<string name="time">Time</string>
<string name="key_show_notes_entry_dialogs" translatable="false">show_notes_entry_dialogs</string>
<string name="overview_show_notes_field_in_dialogs_title">Show notes field in treatment dialogs</string>
<string name="title_activity_setup_wizard" translatable="false">SetupWizardActivity</string>
<string name="next_button">Next</string>
@ -878,46 +857,6 @@
<string name="loop_openmode_min_change">Minimal request change [%]</string>
<string name="loop_openmode_min_change_summary" formatted="false">Open Loop will popup new change request only if change is bigger than this value in %. Default value is 20%</string>
<string name="key_short_tabtitles" translatable="false">short_tabtitles</string>
<string name="weekday_sunday_short">Sun</string>
<string name="weekday_saturday_short">Sat</string>
<string name="weekday_friday_short">Fri</string>
<string name="weekday_thursday_short">Thu</string>
<string name="weekday_wednesday_short">Wed</string>
<string name="weekday_tuesday_short">Tue</string>
<string name="weekday_monday_short">Mon</string>
<string name="automation_description">User defined automation tasks</string>
<string name="automation_missing_task_name">Please enter a task name.</string>
<string name="automation_missing_trigger">Please specify at least one trigger.</string>
<string name="automation_missing_action">Please specify at least one action.</string>
<string name="alreadyenabled">Already enabled</string>
<string name="alreadydisabled">Already disabled</string>
<string name="alreadysuspended">Already suspended</string>
<string name="resumeloop">Resume loop</string>
<string name="notsuspended">Not suspended</string>
<string name="starttemptarget">Start temp target</string>
<string name="stoptemptarget">Stop temp target</string>
<string name="islesser">is lesser than</string>
<string name="isequalorlesser">is equal or lesser than</string>
<string name="isequal">is equal to</string>
<string name="isequalorgreater">is equal or greater than</string>
<string name="isgreater">is greater than</string>
<string name="isnotavailable">is not available</string>
<string name="glucoseisnotavailable">Glucose is not available</string>
<string name="glucosecomparedmgdl">Glucose %1$s %2$.0f %3$s</string>
<string name="glucosecomparedmmol">Glucose %1$s %2$.1f %3$s</string>
<string name="percentagecompared">Profile pct %1$s %2$d</string>
<string name="iobcompared">IOB %1$s %2$.1f</string>
<string name="and">And</string>
<string name="or">Or</string>
<string name="xor">Exclusive or</string>
<string name="atspecifiedtime">At %1$s</string>
<string name="use_network_location">Use network location</string>
<string name="use_gps_location">Use GPS location</string>
<string name="use_passive_location">Use passive location</string>
<string name="locationservice">Location service</string>
<string name="key_location" translatable="false">location</string>
<string name="automation_short">Auto</string>
<string name="automation">Automation</string>
<string name="profile_total">== ∑ %1$s U</string>
<string name="key_dexcom_lognssensorchange" translatable="false">dexcom_lognssensorchange</string>
@ -966,17 +905,6 @@
<string name="sms_wrongcode">Wrong code. Command cancelled.</string>
<string name="notconfigured">Not configured</string>
<string name="profileswitchcreated">Profile switch created</string>
<string name="recurringTime">Recurring time</string>
<string name="every">Every</string>
<string name="never">Never</string>
<string name="condition">Condition:</string>
<string name="action">Action:</string>
<string name="iob_u">IOB [U]:</string>
<string name="glucose_u">Glucose [%1$s]:</string>
<string name="delete_short">DEL</string>
<string name="add_short">ADD</string>
<string name="copy_short">COPY</string>
<string name="addnew">Add new</string>
<string name="versionChecker">Version Checker</string>
<string name="old_version">old version</string>
@ -988,71 +916,13 @@
<string name="dexcom_short">DXCM</string>
<string name="description_source_dexcom">Receive BG values from the patched Dexcom app.</string>
<string name="notification">Notification</string>
<string name="notification_message">Notification: %1$s</string>
<string name="alarm_message">Alarm: %1$s</string>
<string name="message_short">Msg:</string>
<string name="alarm_short">Alarm:</string>
<string name="profilepercentage">Profile percentage</string>
<string name="percent_u">Percent [%]:</string>
<string name="startprofile">Start profile %1$d%% for %2$d min</string>
<string name="startprofileforever">Start profile %1$d%%</string>
<string name="exists">exists</string>
<string name="notexists">not exists</string>
<string name="temptargetcompared">Temp target %1$s</string>
<string name="btdevicecompared">Bluetooth connection to device %1$s %2$s</string>
<string name="btdevice">Connection to Bluetooth device </string>
<string name="wifissidcompared">WiFi SSID %1$s %2$s</string>
<string name="autosenscompared">Autosens %1$s %2$s %%</string>
<string name="autosenslabel">Autosens %</string>
<string name="deltacompared">%3$s %1$s %2$s</string>
<string name="deltalabel">BG difference</string>
<string name="deltalabel_u">BG difference [%1$s]</string>
<string name="currentlocation">Current Location</string>
<string name="location">Location</string>
<string name="latitude_short">Lat:</string>
<string name="longitude_short">Lon:</string>
<string name="distance_short">Dist [m]:</string>
<string name="name_short">Name:</string>
<string name="locationis">%1$s %2$s</string>
<string name="location_mode">When </string>
<string name="location_inside">When you are inside the area</string>
<string name="location_outside">When you are outside the area</string>
<string name="location_going_in">When you enter the area named</string>
<string name="location_going_out">When you leave the area named</string>
<string name="lastboluslabel">Last bolus ago</string>
<string name="lastboluscompared">Last bolus time %1$s %2$s min ago</string>
<string name="triggercoblabel">COB</string>
<string name="cobcompared">COB %1$s %2$.0f</string>
<string name="taskname">Task name</string>
<string name="edit_short">EDIT</string>
<string name="please_choose_an_action_type">Choose an action type</string>
<string name="please_choose_a_trigger_type">Choose a trigger type</string>
<string name="triggers">Triggers:</string>
<string name="remove_label">REMOVE</string>
<string name="preconditions">Preconditions:</string>
<string name="profilename">Change profile to</string>
<string name="changengetoprofilename">Change profile to %1$s</string>
<string name="automation_trigger_pump_last_connection_label">Last connection to pump</string>
<string name="automation_trigger_pump_last_connection_description">Last connection to pump [minutes ago]</string>
<string name="automation_trigger_pump_last_connection_compared">Last connection to pump %1$s %2$s min ago</string>
<string name="sendsmsactionlabel">Send SMS: %1$s</string>
<string name="sendsmsactiondescription">Send SMS to all numbers</string>
<string name="sendsmsactiontext">Send SMS with text</string>
<string name="cobvsiob">COB vs IOB</string>
<string name="bolusconstraintappliedwarn">Bolus constraint applied: %1$.2f U to %2$.2f U</string>
<string name="slowabsorptiondetected"><![CDATA[<font color=\'%1$s\'>!!!!! Slow carbs absorption detected: %2$d%% of time. Double check your calculation. COB can be overestimated thus more insulin could be given !!!!!</font>]]></string>
<string name="key_boluswizard_percentage" translatable="false">boluswizard_percentage</string>
<string name="partialboluswizard">Deliver this part of bolus wizard result [%]</string>
<string name="deliverpartofboluswizard">Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm.</string>
<string name="loading">Loading ...</string>
<string name="snooze">Snooze</string>
<string name="time_range">Time range</string>
<string name="timerange_value">Time is between %1$s and %2$s</string>
<string name="between">Between </string>
<string name="increasingmaxbasal">Increasing max basal value because setting is lower than your max basal in profile</string>
<string name="smscommunicator_messagebody">Invalid message body</string>
@ -1085,7 +955,6 @@
<string name="profilenamecontainsdot">Profile name contains dots.\nThis is not supported by NS.\nProfile is not uploaded to NS.</string>
<string name="low_mark_comment">Lower value of in range area (display only)</string>
<string name="high_mark_comment">Higher value of in range area (display only)</string>
<string name="reorder_label">Reorder</string>
<string name="age">Age:</string>
<string name="weight_label">Weight:</string>
@ -1107,8 +976,6 @@
<string name="randombg_short">BG</string>
<string name="tools">Tools</string>
<string name="show_calculation">Show calcuation</string>
<string name="automation_event">Automation event</string>
<string name="alreadyset">Already set</string>
<string name="clearqueueconfirm">Clear queue? All data in queue will be lost!</string>
<string name="key_xdripstatus_detailediob" translatable="false">xdripstatus_detailediob</string>
<string name="key_xdripstatus_showbgi" translatable="false">xdripstatus_showbgi</string>
@ -1157,8 +1024,6 @@
<string name="smscommunicator_otp_install_info">On each follower phone install Authenticator app that support RFC 6238 TOTP tokens. Popular free apps are:\n • Authy\n • Google Authenticator\n • LastPass Authenticator\n • FreeOTP Authenticator</string>
<string name="smscommunicator_otp_reset_warning">By reseting authenticator you make all already provisioned authenticators invalid. You will need to set up them again!</string>
<string name="onconnect">On connect</string>
<string name="ondisconnect">On disconnect</string>
<string name="overview_show_predictions">Predictions</string>
<string name="overview_show_deviationslope">Deviation slope</string>
<string name="key_graphconfig" translatable="false">graphconfig</string>
@ -1224,7 +1089,6 @@
<string name="filter">Filter</string>
<string name="copytolocalprofile_invalid">Unable to create local profile. Profile is invalid.</string>
<string name="cta_dont_kill_my_app_info">Don\'t kill my app?</string>
<string name="alarm">Alarm</string>
<string name="key_smscommunicator_report_pump_ureachable" translatable="false">smscommunicator_report_pump_ureachable</string>
<string name="smscommunicator_report_pump_ureachable_summary">Send SMS if unreachable pump event is triggered</string>
<string name="smscommunicator_pump_ureachable">Report pump unreachable</string>

1
automation/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

21
automation/build.gradle Normal file
View file

@ -0,0 +1,21 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle"
apply from: "${project.rootDir}/gradle/android_module_dependencies.gradle"
apply from: "${project.rootDir}/gradle/test_dependencies.gradle"
android {
defaultConfig {
versionCode 1
versionName "1.0"
}
}
dependencies {
implementation project(':core')
implementation project(':database')
}

View file

21
automation/proguard-rules.pro vendored Normal file
View file

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.nightscout.androidaps.automation">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<application>
<service
android:name="info.nightscout.androidaps.services.LocationService"
android:exported="false" />
</application>
</manifest>

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.dependencyInjection
package info.nightscout.androidaps.automation.di
import dagger.Module
import dagger.android.ContributesAndroidInjector
@ -6,8 +6,6 @@ import info.nightscout.androidaps.plugins.general.automation.AutomationEvent
import info.nightscout.androidaps.plugins.general.automation.actions.*
import info.nightscout.androidaps.plugins.general.automation.elements.*
import info.nightscout.androidaps.plugins.general.automation.triggers.*
import info.nightscout.androidaps.queue.CommandQueue
import info.nightscout.androidaps.queue.commands.*
@Module
@Suppress("unused")

View file

@ -17,9 +17,9 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import dagger.android.HasAndroidInjector
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.AutomationEventItemBinding
import info.nightscout.androidaps.databinding.AutomationFragmentBinding
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.automation.databinding.AutomationEventItemBinding
import info.nightscout.androidaps.automation.databinding.AutomationFragmentBinding
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog

View file

@ -5,36 +5,31 @@ import android.os.Handler
import android.os.HandlerThread
import android.os.SystemClock
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventBTChange
import info.nightscout.androidaps.events.EventChargingState
import info.nightscout.androidaps.events.EventLocationChange
import info.nightscout.androidaps.events.EventNetworkChange
import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.events.*
import info.nightscout.androidaps.interfaces.ConfigInterface
import info.nightscout.androidaps.interfaces.LoopInterface
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.general.automation.actions.*
import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationDataChanged
import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationUpdateGui
import info.nightscout.androidaps.plugins.general.automation.triggers.*
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.services.LocationServiceHelper
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.T
import io.reactivex.rxkotlin.plusAssign
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.androidaps.utils.sharedPreferences.SP
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.rxkotlin.plusAssign
import org.json.JSONArray
import org.json.JSONException
import org.json.JSONObject
@ -50,12 +45,12 @@ class AutomationPlugin @Inject constructor(
private val context: Context,
private val sp: SP,
private val fabricPrivacy: FabricPrivacy,
private val loopPlugin: LoopPlugin,
private val loopPlugin: LoopInterface,
private val rxBus: RxBusWrapper,
private val constraintChecker: ConstraintChecker,
aapsLogger: AAPSLogger,
private val aapsSchedulers: AapsSchedulers,
private val config: Config,
private val config: ConfigInterface,
private val locationServiceHelper: LocationServiceHelper,
private val dateUtil: DateUtil
) : PluginBase(PluginDescription()
@ -188,7 +183,7 @@ class AutomationPlugin @Inject constructor(
private fun processActions() {
var userEventsEnabled = config.APS
if (config.APS) {
if (loopPlugin.isSuspended || !loopPlugin.isEnabled()) {
if (loopPlugin.isSuspended || !(loopPlugin as PluginBase).isEnabled()) {
aapsLogger.debug(LTag.AUTOMATION, "Loop deactivated")
executionLog.add(resourceHelper.gs(R.string.smscommunicator_loopisdisabled))
userEventsEnabled = false

View file

@ -4,7 +4,7 @@ import android.content.Context
import android.widget.LinearLayout
import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.automation.elements.InputString

View file

@ -2,22 +2,23 @@ package info.nightscout.androidaps.plugins.general.automation.actions
import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface
import info.nightscout.androidaps.interfaces.LoopInterface
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject
class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var loopPlugin: LoopPlugin
@Inject lateinit var loopPlugin: LoopInterface
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
@Inject lateinit var configBuilderPlugin: ConfigBuilderInterface
@Inject lateinit var commandQueue: CommandQueueProvider
@Inject lateinit var rxBus: RxBusWrapper
@ -26,8 +27,8 @@ class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) {
@DrawableRes override fun icon(): Int = R.drawable.ic_stop_24dp
override fun doAction(callback: Callback) {
if (loopPlugin.isEnabled(PluginType.LOOP)) {
loopPlugin.setPluginEnabled(PluginType.LOOP, false)
if ((loopPlugin as PluginBase).isEnabled()) {
(loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, false)
configBuilderPlugin.storeSettings("ActionLoopDisable")
commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() {

View file

@ -2,13 +2,14 @@ package info.nightscout.androidaps.plugins.general.automation.actions
import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface
import info.nightscout.androidaps.interfaces.LoopInterface
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject
@ -16,8 +17,8 @@ import javax.inject.Inject
class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var loopPlugin: LoopPlugin
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
@Inject lateinit var loopPlugin: LoopInterface
@Inject lateinit var configBuilderPlugin: ConfigBuilderInterface
@Inject lateinit var rxBus: RxBusWrapper
override fun friendlyName(): Int = R.string.enableloop
@ -25,8 +26,8 @@ class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) {
@DrawableRes override fun icon(): Int = R.drawable.ic_play_circle_outline_24dp
override fun doAction(callback: Callback) {
if (!loopPlugin.isEnabled(PluginType.LOOP)) {
loopPlugin.setPluginEnabled(PluginType.LOOP, true)
if (!(loopPlugin as PluginBase).isEnabled()) {
(loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, true)
configBuilderPlugin.storeSettings("ActionLoopEnable")
rxBus.send(EventRefreshOverview("ActionLoopEnable"))
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()

View file

@ -2,20 +2,20 @@ package info.nightscout.androidaps.plugins.general.automation.actions
import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface
import info.nightscout.androidaps.interfaces.LoopInterface
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject
class ActionLoopResume(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var loopPlugin: LoopPlugin
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
@Inject lateinit var loopPlugin: LoopInterface
@Inject lateinit var configBuilderPlugin: ConfigBuilderInterface
@Inject lateinit var rxBus: RxBusWrapper
override fun friendlyName(): Int = R.string.resumeloop

View file

@ -3,10 +3,10 @@ package info.nightscout.androidaps.plugins.general.automation.actions
import android.widget.LinearLayout
import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.interfaces.LoopInterface
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
@ -19,7 +19,7 @@ import javax.inject.Inject
class ActionLoopSuspend(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var loopPlugin: LoopPlugin
@Inject lateinit var loopPlugin: LoopInterface
@Inject lateinit var rxBus: RxBusWrapper
var minutes = InputDuration(injector, 30, InputDuration.TimeUnit.MINUTES)

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.actions
import android.widget.LinearLayout
import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
@ -20,6 +20,7 @@ import org.json.JSONObject
import javax.inject.Inject
class ActionNotification(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var nsUpload: NSUpload

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.actions
import android.widget.LinearLayout
import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.logging.LTag

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.actions
import android.widget.LinearLayout
import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator

View file

@ -2,12 +2,12 @@ package info.nightscout.androidaps.plugins.general.automation.actions
import android.widget.LinearLayout
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.interfaces.SmsCommunicatorInterface
import info.nightscout.androidaps.plugins.general.automation.elements.InputString
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.JsonHelper
import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -17,7 +17,7 @@ import javax.inject.Inject
class ActionSendSMS(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorInterface
var text = InputString(injector)

View file

@ -4,7 +4,7 @@ import android.widget.LinearLayout
import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.db.Source

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.general.automation.actions
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.db.Source
import info.nightscout.androidaps.db.TempTarget

View file

@ -5,8 +5,8 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.RadioButton
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.databinding.AutomationDialogChooseActionBinding
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.automation.databinding.AutomationDialogChooseActionBinding
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin
@ -20,7 +20,7 @@ class ChooseActionDialog : DialogFragmentWithDate() {
@Inject lateinit var automationPlugin: AutomationPlugin
@Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var mainApp: MainApp
@Inject lateinit var injector: HasAndroidInjector
private var checkedIndex = -1
@ -31,7 +31,7 @@ class ChooseActionDialog : DialogFragmentWithDate() {
private val binding get() = _binding!!
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
savedInstanceState: Bundle?): View {
// restore checked radio button
savedInstanceState?.let { bundle ->
checkedIndex = bundle.getInt("checkedIndex")
@ -77,7 +77,7 @@ class ChooseActionDialog : DialogFragmentWithDate() {
private fun instantiateAction(): Action? {
return getActionClass()?.let {
val clazz = Class.forName(it).kotlin
clazz.primaryConstructor?.call(mainApp) as Action
clazz.primaryConstructor?.call(injector) as Action
}
}

View file

@ -5,8 +5,8 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.RadioButton
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.databinding.AutomationDialogChooseTriggerBinding
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.automation.databinding.AutomationDialogChooseTriggerBinding
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin
import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger
@ -16,7 +16,7 @@ import kotlin.reflect.full.primaryConstructor
class ChooseTriggerDialog : DialogFragmentWithDate() {
@Inject lateinit var automationPlugin: AutomationPlugin
@Inject lateinit var mainApp: MainApp
@Inject lateinit var injector: HasAndroidInjector
private var checkedIndex = -1
private var clickListener: OnClickListener? = null
@ -82,7 +82,7 @@ class ChooseTriggerDialog : DialogFragmentWithDate() {
private fun instantiateTrigger(): Trigger? {
return getTriggerClass()?.let {
val clazz = Class.forName(it).kotlin
clazz.primaryConstructor?.call(mainApp) as Trigger
clazz.primaryConstructor?.call(injector) as Trigger
}
}

View file

@ -4,8 +4,8 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.databinding.AutomationDialogActionBinding
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.automation.databinding.AutomationDialogActionBinding
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.automation.actions.Action
@ -17,7 +17,7 @@ import javax.inject.Inject
class EditActionDialog : DialogFragmentWithDate() {
@Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var mainApp: MainApp
@Inject lateinit var injector: HasAndroidInjector
private var action: Action? = null
private var actionPosition: Int = -1
@ -33,7 +33,7 @@ class EditActionDialog : DialogFragmentWithDate() {
// load data from bundle
(savedInstanceState ?: arguments)?.let { bundle ->
actionPosition = bundle.getInt("actionPosition", -1)
bundle.getString("action")?.let { action = ActionDummy(mainApp).instantiate(JSONObject(it)) }
bundle.getString("action")?.let { action = ActionDummy(injector).instantiate(JSONObject(it)) }
}
onCreateViewGeneral()
_binding = AutomationDialogActionBinding.inflate(inflater, container, false)

View file

@ -10,8 +10,8 @@ import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.AutomationDialogEventBinding
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.automation.databinding.AutomationDialogEventBinding
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.automation.AutomationEvent

View file

@ -5,7 +5,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.databinding.AutomationDialogEditTriggerBinding
import info.nightscout.androidaps.automation.databinding.AutomationDialogEditTriggerBinding
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationUpdateTrigger

View file

@ -7,7 +7,7 @@ import android.widget.LinearLayout
import android.widget.Spinner
import androidx.annotation.StringRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.utils.resources.ResourceHelper
import java.util.*
import javax.inject.Inject

View file

@ -7,7 +7,7 @@ import android.widget.LinearLayout
import android.widget.Spinner
import androidx.annotation.StringRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.utils.resources.ResourceHelper
import java.util.*
import javax.inject.Inject

View file

@ -7,7 +7,7 @@ import android.widget.LinearLayout
import android.widget.Spinner
import androidx.annotation.StringRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.utils.resources.ResourceHelper
import java.util.*
import javax.inject.Inject

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import android.widget.LinearLayout
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.ui.NumberPicker
import java.text.DecimalFormat

View file

@ -9,7 +9,7 @@ import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.resources.ResourceHelper
import java.util.*
@ -22,7 +22,7 @@ class InputDateTime(injector: HasAndroidInjector) : Element(injector) {
var value: Long = DateUtil.now()
constructor(injector: HasAndroidInjector, value: Long) : this(injector) {
@Suppress("unused") constructor(injector: HasAndroidInjector, value: Long) : this(injector) {
this.value = value
}

View file

@ -8,7 +8,7 @@ import android.widget.LinearLayout
import android.widget.Spinner
import androidx.annotation.StringRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.utils.ui.NumberPicker
import info.nightscout.androidaps.utils.resources.ResourceHelper
import java.text.DecimalFormat

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import android.widget.LinearLayout
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.utils.ui.NumberPicker
import java.text.DecimalFormat

View file

@ -7,7 +7,7 @@ import android.widget.ArrayAdapter
import android.widget.LinearLayout
import android.widget.Spinner
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.utils.resources.ResourceHelper
import java.util.*
import javax.inject.Inject
@ -22,7 +22,7 @@ class InputDropdownMenu(injector: HasAndroidInjector) : Element(injector) {
value = name
}
constructor(injector: HasAndroidInjector, another: InputDropdownMenu) : this(injector) {
@Suppress("unused") constructor(injector: HasAndroidInjector, another: InputDropdownMenu) : this(injector) {
value = another.value
}

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import android.widget.LinearLayout
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.utils.ui.MinutesNumberPicker
import info.nightscout.androidaps.utils.ui.NumberPicker
import java.text.DecimalFormat

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import android.widget.LinearLayout
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.utils.ui.NumberPicker
import java.text.DecimalFormat

View file

@ -7,7 +7,7 @@ import android.widget.LinearLayout
import android.widget.Spinner
import androidx.annotation.StringRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.utils.resources.ResourceHelper
import java.util.*
import javax.inject.Inject

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import android.widget.LinearLayout
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.utils.ui.NumberPicker
import java.text.DecimalFormat

View file

@ -7,7 +7,7 @@ import android.widget.ArrayAdapter
import android.widget.LinearLayout
import android.widget.Spinner
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import android.widget.LinearLayout
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.ui.NumberPicker
import java.text.DecimalFormat

View file

@ -8,7 +8,7 @@ import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.MidnightTime

View file

@ -8,7 +8,7 @@ import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.MidnightTime

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import android.widget.LinearLayout
import androidx.annotation.StringRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.utils.ui.WeekdayPicker
import java.util.*

View file

@ -9,8 +9,9 @@ import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.google.common.base.Optional
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.TreatmentsInterface
import info.nightscout.androidaps.logging.AAPSLogger
@ -19,7 +20,6 @@ import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseTrigg
import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerChanged
import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerClone
import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerRemove
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.services.LastLocationDataContainer
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
@ -38,7 +38,7 @@ abstract class Trigger(val injector: HasAndroidInjector) {
@Inject lateinit var locationDataContainer: LastLocationDataContainer
@Inject lateinit var treatmentsInterface: TreatmentsInterface
@Inject lateinit var activePlugin: ActivePluginProvider
@Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin
@Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorInterface
init {
injector.androidInjector().inject(this)
@ -57,11 +57,11 @@ abstract class Trigger(val injector: HasAndroidInjector) {
@JvmStatic
fun scanForActivity(cont: Context?): AppCompatActivity? {
when (cont) {
null -> return null
is AppCompatActivity -> return cont
is ContextWrapper -> return scanForActivity(cont.baseContext)
else -> return null
return when (cont) {
null -> null
is AppCompatActivity -> cont
is ContextWrapper -> scanForActivity(cont.baseContext)
else -> null
}
}
}

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
import android.widget.LinearLayout
import com.google.common.base.Optional
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
import info.nightscout.androidaps.plugins.general.automation.elements.InputDouble
@ -68,7 +68,7 @@ class TriggerAutosensValue(injector: HasAndroidInjector) : Trigger(injector) {
override fun friendlyDescription(): String =
resourceHelper.gs(R.string.autosenscompared, resourceHelper.gs(comparator.value.stringRes), autosens.value)
override fun icon(): Optional<Int?> = Optional.of(R.drawable.`ic_as`)
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_as)
override fun duplicate(): Trigger = TriggerAutosensValue(injector, this)

View file

@ -5,7 +5,7 @@ import android.content.Context
import android.widget.LinearLayout
import com.google.common.base.Optional
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.events.EventBTChange
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin

View file

@ -4,7 +4,7 @@ import android.widget.LinearLayout
import com.google.common.base.Optional
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
import android.widget.LinearLayout
import com.google.common.base.Optional
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
import android.widget.LinearLayout
import com.google.common.base.Optional
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
import info.nightscout.androidaps.plugins.general.automation.elements.InputDouble
@ -47,7 +47,7 @@ class TriggerCOB(injector: HasAndroidInjector) : Trigger(injector) {
false
}
}
if (comparator.value.check(cobInfo.displayCob, cob.value)) {
if (cobInfo.displayCob != null && comparator.value.check(cobInfo.displayCob!!, cob.value)) {
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
return true
}

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