ActivityNames -> UiInteraction

This commit is contained in:
Milos Kozak 2022-11-28 21:12:41 +01:00
parent b4c1f46c32
commit 11f71d8cb4
124 changed files with 528 additions and 530 deletions

View file

@ -36,7 +36,7 @@ import info.nightscout.interfaces.LocalAlertUtils
import info.nightscout.interfaces.logging.UserEntryLogger import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.versionChecker.VersionCheckerUtils import info.nightscout.interfaces.versionChecker.VersionCheckerUtils
import info.nightscout.plugins.general.overview.notifications.NotificationStore import info.nightscout.plugins.general.overview.notifications.NotificationStore
import info.nightscout.plugins.general.themes.ThemeSwitcherPlugin import info.nightscout.plugins.general.themes.ThemeSwitcherPlugin
@ -74,7 +74,7 @@ class MainApp : DaggerApplication() {
@Inject lateinit var dateUtil: DateUtil @Inject lateinit var dateUtil: DateUtil
@Suppress("unused") @Inject lateinit var staticInjector: info.nightscout.plugins.aps.utils.StaticInjector// TODO avoid , here fake only to initialize @Suppress("unused") @Inject lateinit var staticInjector: info.nightscout.plugins.aps.utils.StaticInjector// TODO avoid , here fake only to initialize
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
@Inject lateinit var notificationStore: NotificationStore @Inject lateinit var notificationStore: NotificationStore
@Inject lateinit var processLifecycleListener: Provider<ProcessLifecycleListener> @Inject lateinit var processLifecycleListener: Provider<ProcessLifecycleListener>
@Inject lateinit var profileSwitchPlugin: ThemeSwitcherPlugin @Inject lateinit var profileSwitchPlugin: ThemeSwitcherPlugin
@ -247,7 +247,7 @@ class MainApp : DaggerApplication() {
override fun onTerminate() { override fun onTerminate() {
aapsLogger.debug(LTag.CORE, "onTerminate") aapsLogger.debug(LTag.CORE, "onTerminate")
unregisterActivityLifecycleCallbacks(activityMonitor) unregisterActivityLifecycleCallbacks(activityMonitor)
activityNames.stopAlarm("onTerminate") uiInteraction.stopAlarm("onTerminate")
super.onTerminate() super.onTerminate()
} }
} }

View file

@ -7,14 +7,14 @@ import dagger.Module
import dagger.Provides import dagger.Provides
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.implementations.ActivityNamesImpl import info.nightscout.androidaps.implementations.UiInteractionImpl
import info.nightscout.androidaps.implementations.ConfigImpl import info.nightscout.androidaps.implementations.ConfigImpl
import info.nightscout.androidaps.workflow.CalculationWorkflowImpl import info.nightscout.androidaps.workflow.CalculationWorkflowImpl
import info.nightscout.androidaps.workflow.WorkerClassesImpl import info.nightscout.androidaps.workflow.WorkerClassesImpl
import info.nightscout.core.workflow.CalculationWorkflow import info.nightscout.core.workflow.CalculationWorkflow
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.workflow.WorkerClasses import info.nightscout.interfaces.workflow.WorkerClasses
@Suppress("unused") @Suppress("unused")
@ -50,7 +50,7 @@ open class AppModule {
@Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector @Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector
@Binds fun bindConfigInterface(config: ConfigImpl): Config @Binds fun bindConfigInterface(config: ConfigImpl): Config
@Binds fun bindActivityNames(activityNames: ActivityNamesImpl): ActivityNames @Binds fun bindActivityNames(activityNames: UiInteractionImpl): UiInteraction
@Binds fun bindWorkerClasses(workerClassesImpl: WorkerClassesImpl): WorkerClasses @Binds fun bindWorkerClasses(workerClassesImpl: WorkerClassesImpl): WorkerClasses
@Binds fun bindCalculationWorkflow(calculationWorkflow: CalculationWorkflowImpl): CalculationWorkflow @Binds fun bindCalculationWorkflow(calculationWorkflow: CalculationWorkflowImpl): CalculationWorkflow
} }

View file

@ -19,7 +19,7 @@ import info.nightscout.core.services.AlarmSoundServiceHelper
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.nsclient.NSAlarm import info.nightscout.interfaces.nsclient.NSAlarm
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.plugins.general.overview.notifications.NotificationWithAction import info.nightscout.plugins.general.overview.notifications.NotificationWithAction
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.ui.activities.BolusProgressHelperActivity import info.nightscout.ui.activities.BolusProgressHelperActivity
@ -41,12 +41,12 @@ import info.nightscout.ui.dialogs.TreatmentDialog
import info.nightscout.ui.dialogs.WizardDialog import info.nightscout.ui.dialogs.WizardDialog
import javax.inject.Inject import javax.inject.Inject
class ActivityNamesImpl @Inject constructor( class UiInteractionImpl @Inject constructor(
private val context: Context, private val context: Context,
private val rxBus: RxBus, private val rxBus: RxBus,
private val injector: HasAndroidInjector, private val injector: HasAndroidInjector,
private val alarmSoundServiceHelper: AlarmSoundServiceHelper private val alarmSoundServiceHelper: AlarmSoundServiceHelper
) : ActivityNames { ) : UiInteraction {
override val mainActivity: Class<*> = MainActivity::class.java override val mainActivity: Class<*> = MainActivity::class.java
override val tddStatsActivity: Class<*> = TDDStatsActivity::class.java override val tddStatsActivity: Class<*> = TDDStatsActivity::class.java
@ -129,7 +129,7 @@ class ActivityNamesImpl @Inject constructor(
.show(fragmentManager, "FillDialog") .show(fragmentManager, "FillDialog")
} }
override fun runProfileViewerDialog(fragmentManager: FragmentManager, time: Long, mode: ActivityNames.Mode, customProfile: String?, customProfileName: String?, customProfile2: String?) { override fun runProfileViewerDialog(fragmentManager: FragmentManager, time: Long, mode: UiInteraction.Mode, customProfile: String?, customProfileName: String?, customProfile2: String?) {
ProfileViewerDialog() ProfileViewerDialog()
.also { .also {
it.arguments = Bundle().also { bundle -> it.arguments = Bundle().also { bundle ->
@ -143,7 +143,7 @@ class ActivityNamesImpl @Inject constructor(
.show(fragmentManager, "ProfileViewer") .show(fragmentManager, "ProfileViewer")
} }
override fun runCareDialog(fragmentManager: FragmentManager, options: ActivityNames.EventType, @StringRes event: Int) { override fun runCareDialog(fragmentManager: FragmentManager, options: UiInteraction.EventType, @StringRes event: Int) {
CareDialog() CareDialog()
.also { .also {
it.arguments = Bundle().also { bundle -> it.arguments = Bundle().also { bundle ->

View file

@ -29,7 +29,7 @@ import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HardLimits import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.plugins.aps.openAPSAMA.OpenAPSAMAPlugin import info.nightscout.plugins.aps.openAPSAMA.OpenAPSAMAPlugin
import info.nightscout.plugins.aps.openAPSSMB.OpenAPSSMBPlugin import info.nightscout.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
@ -68,7 +68,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
@Mock lateinit var pumpSync: PumpSync @Mock lateinit var pumpSync: PumpSync
@Mock lateinit var insightDatabaseDao: InsightDatabaseDao @Mock lateinit var insightDatabaseDao: InsightDatabaseDao
@Mock lateinit var ruffyScripter: RuffyScripter @Mock lateinit var ruffyScripter: RuffyScripter
@Mock lateinit var activityNames: ActivityNames @Mock lateinit var uiInteraction: UiInteraction
@Mock lateinit var profileInstantiator: ProfileInstantiator @Mock lateinit var profileInstantiator: ProfileInstantiator
@Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase @Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase
@Mock lateinit var insightDatabase: InsightDatabase @Mock lateinit var insightDatabase: InsightDatabase
@ -142,9 +142,9 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
insightDbHelper = InsightDbHelper(insightDatabaseDao) insightDbHelper = InsightDbHelper(insightDatabaseDao)
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator) danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, rh, activePlugin, sp, config) objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, rh, activePlugin, sp, config)
comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, rh, profileFunction, sp, commandQueue, pumpSync, dateUtil, ruffyScripter, activityNames) comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, rh, profileFunction, sp, commandQueue, pumpSync, dateUtil, ruffyScripter, uiInteraction)
danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync, danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync,
activityNames, danaHistoryDatabase) uiInteraction, danaHistoryDatabase)
danaRSPlugin = danaRSPlugin =
info.nightscout.pump.danars.DanaRSPlugin( info.nightscout.pump.danars.DanaRSPlugin(
injector, injector,
@ -163,7 +163,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
temporaryBasalStorage, temporaryBasalStorage,
fabricPrivacy, fabricPrivacy,
dateUtil, dateUtil,
activityNames, uiInteraction,
danaHistoryDatabase danaHistoryDatabase
) )
insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, rh, sp, commandQueue, profileFunction, context, config, dateUtil, insightDbHelper, pumpSync, insightDatabase) insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, rh, sp, commandQueue, profileFunction, context, config, dateUtil, insightDbHelper, pumpSync, insightDatabase)

View file

@ -18,7 +18,7 @@ import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.plugins.aps.loop.LoopFragment import info.nightscout.plugins.aps.loop.LoopFragment
import info.nightscout.plugins.aps.loop.LoopPlugin import info.nightscout.plugins.aps.loop.LoopPlugin
import info.nightscout.interfaces.configBuilder.RunningConfiguration import info.nightscout.interfaces.configBuilder.RunningConfiguration
@ -53,7 +53,7 @@ class LoopPluginTest : TestBase() {
@Mock lateinit var dateUtil: DateUtil @Mock lateinit var dateUtil: DateUtil
@Mock lateinit var runningConfiguration: RunningConfiguration @Mock lateinit var runningConfiguration: RunningConfiguration
@Mock lateinit var config: Config @Mock lateinit var config: Config
@Mock lateinit var activityNames: ActivityNames @Mock lateinit var uiInteraction: UiInteraction
private lateinit var loopPlugin: LoopPlugin private lateinit var loopPlugin: LoopPlugin
@ -62,7 +62,7 @@ class LoopPluginTest : TestBase() {
loopPlugin = LoopPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, config, loopPlugin = LoopPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, config,
constraintChecker, rh, profileFunction, context, commandQueue, activePlugin, virtualPumpPlugin, iobCobCalculator, receiverStatusStore, fabricPrivacy, dateUtil, uel, constraintChecker, rh, profileFunction, context, commandQueue, activePlugin, virtualPumpPlugin, iobCobCalculator, receiverStatusStore, fabricPrivacy, dateUtil, uel,
repository, runningConfiguration, activityNames) repository, runningConfiguration, uiInteraction)
`when`(activePlugin.activePump).thenReturn(virtualPumpPlugin) `when`(activePlugin.activePump).thenReturn(virtualPumpPlugin)
`when`(context.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(notificationManager) `when`(context.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(notificationManager)
} }

View file

@ -36,7 +36,7 @@ import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HtmlHelper import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -73,7 +73,7 @@ class BolusWizard @Inject constructor(
@Inject lateinit var carbTimer: CarbTimer @Inject lateinit var carbTimer: CarbTimer
@Inject lateinit var bolusTimer: BolusTimer @Inject lateinit var bolusTimer: BolusTimer
@Inject lateinit var glucoseStatusProvider: GlucoseStatusProvider @Inject lateinit var glucoseStatusProvider: GlucoseStatusProvider
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
@Inject lateinit var persistenceLayer: PersistenceLayer @Inject lateinit var persistenceLayer: PersistenceLayer
@ -400,7 +400,7 @@ class BolusWizard @Inject constructor(
commandQueue.bolus(this, object : Callback() { commandQueue.bolus(this, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
activityNames.runAlarm(result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror) uiInteraction.runAlarm(result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
} else } else
carbTimer.scheduleAutomationEventEatReminder() carbTimer.scheduleAutomationEventEatReminder()
} }
@ -447,7 +447,7 @@ class BolusWizard @Inject constructor(
commandQueue.tempBasalAbsolute(0.0, 120, true, profile, PumpSync.TemporaryBasalType.NORMAL, object : Callback() { commandQueue.tempBasalAbsolute(0.0, 120, true, profile, PumpSync.TemporaryBasalType.NORMAL, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
activityNames.runAlarm(result.comment, rh.gs(R.string.temp_basal_delivery_error), R.raw.boluserror) uiInteraction.runAlarm(result.comment, rh.gs(R.string.temp_basal_delivery_error), R.raw.boluserror)
} }
} }
}) })
@ -455,7 +455,7 @@ class BolusWizard @Inject constructor(
commandQueue.tempBasalPercent(0, 120, true, profile, PumpSync.TemporaryBasalType.NORMAL, object : Callback() { commandQueue.tempBasalPercent(0, 120, true, profile, PumpSync.TemporaryBasalType.NORMAL, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
activityNames.runAlarm(result.comment, rh.gs(R.string.temp_basal_delivery_error), R.raw.boluserror) uiInteraction.runAlarm(result.comment, rh.gs(R.string.temp_basal_delivery_error), R.raw.boluserror)
} }
} }
}) })
@ -486,7 +486,7 @@ class BolusWizard @Inject constructor(
commandQueue.bolus(this, object : Callback() { commandQueue.bolus(this, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
activityNames.runAlarm(result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror) uiInteraction.runAlarm(result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
} }
} }
}) })

View file

@ -29,7 +29,6 @@
<string name="target_long_label">Blood Glucose Target</string> <string name="target_long_label">Blood Glucose Target</string>
<string name="shortgram">g</string> <string name="shortgram">g</string>
<string name="shortpercent">%</string> <string name="shortpercent">%</string>
<string name="advancedsettings_title">Advanced Settings</string>
<string name="bluetooth">Bluetooth</string> <string name="bluetooth">Bluetooth</string>
<string name="btwatchdog_title">BT Watchdog</string> <string name="btwatchdog_title">BT Watchdog</string>
<string name="btwatchdog_summary">Switches off the phone\'s bluetooth for one second if no connection to the pump is possible. This may help on some phones where the bluetooth stack freezes.</string> <string name="btwatchdog_summary">Switches off the phone\'s bluetooth for one second if no connection to the pump is possible. This may help on some phones where the bluetooth stack freezes.</string>

View file

@ -11,7 +11,7 @@ import info.nightscout.interfaces.nsclient.NSAlarm
* Interface to use activities located in different modules * Interface to use activities located in different modules
* usage: startActivity(Intent(context, activityNames.xxxx)) * usage: startActivity(Intent(context, activityNames.xxxx))
*/ */
interface ActivityNames { interface UiInteraction {
val mainActivity: Class<*> val mainActivity: Class<*>
val tddStatsActivity: Class<*> val tddStatsActivity: Class<*>

View file

@ -45,6 +45,7 @@
<string name="mute5min">Mute for 5 minutes</string> <string name="mute5min">Mute for 5 minutes</string>
<string name="mute">Mute</string> <string name="mute">Mute</string>
<string name="success">Success</string> <string name="success">Success</string>
<string name="advancedsettings_title">Advanced Settings</string>
<!-- Protection--> <!-- Protection-->
<string name="unlock_settings">Unlock settings</string> <string name="unlock_settings">Unlock settings</string>

View file

@ -5,7 +5,7 @@ import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertTherapyEventAnnouncementTransaction import info.nightscout.database.impl.transactions.InsertTherapyEventAnnouncementTransaction
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HardLimits import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
@ -21,7 +21,7 @@ import kotlin.math.min
@Singleton @Singleton
class HardLimitsImpl @Inject constructor( class HardLimitsImpl @Inject constructor(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val activityNames: ActivityNames, private val uiInteraction: UiInteraction,
private val sp: SP, private val sp: SP,
private val rh: ResourceHelper, private val rh: ResourceHelper,
private val context: Context, private val context: Context,
@ -100,7 +100,7 @@ class HardLimitsImpl @Inject constructor(
msg += rh.gs(R.string.valuelimitedto, value, newValue) msg += rh.gs(R.string.valuelimitedto, value, newValue)
aapsLogger.error(msg) aapsLogger.error(msg)
disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(msg)).subscribe() disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(msg)).subscribe()
activityNames.showToastAndNotification(context, msg, R.raw.error) uiInteraction.showToastAndNotification(context, msg, R.raw.error)
} }
return newValue return newValue
} }

View file

@ -10,7 +10,7 @@ import androidx.core.app.NotificationCompat
import androidx.core.app.TaskStackBuilder import androidx.core.app.TaskStackBuilder
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.interfaces.NotificationHolder import info.nightscout.interfaces.NotificationHolder
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.ui.IconsProvider import info.nightscout.interfaces.ui.IconsProvider
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import javax.inject.Inject import javax.inject.Inject
@ -21,7 +21,7 @@ class NotificationHolderImpl @Inject constructor(
private val rh: ResourceHelper, private val rh: ResourceHelper,
private val context: Context, private val context: Context,
private val iconsProvider: IconsProvider, private val iconsProvider: IconsProvider,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) : NotificationHolder { ) : NotificationHolder {
override val channelID = "AndroidAPS-Ongoing" override val channelID = "AndroidAPS-Ongoing"
@ -34,8 +34,8 @@ class NotificationHolderImpl @Inject constructor(
get() = _notification ?: placeholderNotification() get() = _notification ?: placeholderNotification()
override fun openAppIntent(context: Context): PendingIntent? = TaskStackBuilder.create(context).run { override fun openAppIntent(context: Context): PendingIntent? = TaskStackBuilder.create(context).run {
addParentStack(activityNames.mainActivity) addParentStack(uiInteraction.mainActivity)
addNextIntent(Intent(context, activityNames.mainActivity)) addNextIntent(Intent(context, uiInteraction.mainActivity))
getPendingIntent(0, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) getPendingIntent(0, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
} }

View file

@ -53,7 +53,7 @@ import info.nightscout.interfaces.queue.Command
import info.nightscout.interfaces.queue.Command.CommandType import info.nightscout.interfaces.queue.Command.CommandType
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.queue.CustomCommand import info.nightscout.interfaces.queue.CustomCommand
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HtmlHelper import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -91,7 +91,7 @@ class CommandQueueImplementation @Inject constructor(
private val repository: AppRepository, private val repository: AppRepository,
private val fabricPrivacy: FabricPrivacy, private val fabricPrivacy: FabricPrivacy,
private val androidPermission: AndroidPermission, private val androidPermission: AndroidPermission,
private val activityNames: ActivityNames, private val uiInteraction: UiInteraction,
private val persistenceLayer: PersistenceLayer private val persistenceLayer: PersistenceLayer
) : CommandQueue { ) : CommandQueue {
@ -117,7 +117,7 @@ class CommandQueueImplementation @Inject constructor(
setProfile(ProfileSealed.PS(it), it.interfaceIDs.nightscoutId != null, object : Callback() { setProfile(ProfileSealed.PS(it), it.interfaceIDs.nightscoutId != null, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
activityNames.runAlarm(result.comment, rh.gs(R.string.failed_update_basal_profile), R.raw.boluserror) uiInteraction.runAlarm(result.comment, rh.gs(R.string.failed_update_basal_profile), R.raw.boluserror)
} else { } else {
val nonCustomized = ProfileSealed.PS(it).convertToNonCustomizedProfile(dateUtil) val nonCustomized = ProfileSealed.PS(it).convertToNonCustomizedProfile(dateUtil)
EffectiveProfileSwitch( EffectiveProfileSwitch(
@ -230,7 +230,7 @@ class CommandQueueImplementation @Inject constructor(
val tempCommandQueue = CommandQueueImplementation( val tempCommandQueue = CommandQueueImplementation(
injector, aapsLogger, rxBus, aapsSchedulers, rh, injector, aapsLogger, rxBus, aapsSchedulers, rh,
constraintChecker, profileFunction, activePlugin, context, sp, constraintChecker, profileFunction, activePlugin, context, sp,
config, dateUtil, repository, fabricPrivacy, androidPermission, activityNames, persistenceLayer config, dateUtil, repository, fabricPrivacy, androidPermission, uiInteraction, persistenceLayer
) )
tempCommandQueue.readStatus(reason, callback) tempCommandQueue.readStatus(reason, callback)
tempCommandQueue.disposable.clear() tempCommandQueue.disposable.clear()
@ -613,7 +613,7 @@ class CommandQueueImplementation @Inject constructor(
private fun showBolusProgressDialog(detailedBolusInfo: DetailedBolusInfo) { private fun showBolusProgressDialog(detailedBolusInfo: DetailedBolusInfo) {
if (detailedBolusInfo.context != null) { if (detailedBolusInfo.context != null) {
activityNames.runBolusProgressDialog( uiInteraction.runBolusProgressDialog(
(detailedBolusInfo.context as AppCompatActivity).supportFragmentManager, (detailedBolusInfo.context as AppCompatActivity).supportFragmentManager,
detailedBolusInfo.insulin, detailedBolusInfo.insulin,
detailedBolusInfo.id detailedBolusInfo.id
@ -622,7 +622,7 @@ class CommandQueueImplementation @Inject constructor(
val i = Intent() val i = Intent()
i.putExtra("insulin", detailedBolusInfo.insulin) i.putExtra("insulin", detailedBolusInfo.insulin)
i.putExtra("id", detailedBolusInfo.id) i.putExtra("id", detailedBolusInfo.id)
i.setClass(context, activityNames.bolusProgressHelperActivity) i.setClass(context, uiInteraction.bolusProgressHelperActivity)
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(i) context.startActivity(i)
} }

View file

@ -30,7 +30,7 @@ import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.interfaces.queue.CustomCommand import info.nightscout.interfaces.queue.CustomCommand
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -55,7 +55,7 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
@Mock lateinit var sp: SP @Mock lateinit var sp: SP
@Mock lateinit var powerManager: PowerManager @Mock lateinit var powerManager: PowerManager
@Mock lateinit var repository: AppRepository @Mock lateinit var repository: AppRepository
@Mock lateinit var activityNames: ActivityNames @Mock lateinit var uiInteraction: UiInteraction
@Mock lateinit var androidPermission: AndroidPermission @Mock lateinit var androidPermission: AndroidPermission
@Mock lateinit var persistenceLayer: PersistenceLayer @Mock lateinit var persistenceLayer: PersistenceLayer
@ -75,12 +75,12 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
repository: AppRepository, repository: AppRepository,
fabricPrivacy: FabricPrivacy, fabricPrivacy: FabricPrivacy,
androidPermission: AndroidPermission, androidPermission: AndroidPermission,
activityNames: ActivityNames, uiInteraction: UiInteraction,
persistenceLayer: PersistenceLayer persistenceLayer: PersistenceLayer
) : CommandQueueImplementation( ) : CommandQueueImplementation(
injector, aapsLogger, rxBus, aapsSchedulers, rh, constraintChecker, profileFunction, injector, aapsLogger, rxBus, aapsSchedulers, rh, constraintChecker, profileFunction,
activePlugin, context, sp, config, dateUtil, repository, fabricPrivacy, activePlugin, context, sp, config, dateUtil, repository, fabricPrivacy,
androidPermission, activityNames, persistenceLayer androidPermission, uiInteraction, persistenceLayer
) { ) {
override fun notifyAboutNewCommand() : Boolean = true override fun notifyAboutNewCommand() : Boolean = true
@ -124,7 +124,7 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
injector, aapsLogger, rxBus, aapsSchedulers, rh, injector, aapsLogger, rxBus, aapsSchedulers, rh,
constraintChecker, profileFunction, activePlugin, context, sp, constraintChecker, profileFunction, activePlugin, context, sp,
config, dateUtil, repository, config, dateUtil, repository,
fabricPrivacy, androidPermission, activityNames, persistenceLayer fabricPrivacy, androidPermission, uiInteraction, persistenceLayer
) )
testPumpPlugin = TestPumpPlugin(injector) testPumpPlugin = TestPumpPlugin(injector)
@ -161,7 +161,7 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
val commandQueue = CommandQueueImplementation( val commandQueue = CommandQueueImplementation(
injector, aapsLogger, rxBus, aapsSchedulers, rh, injector, aapsLogger, rxBus, aapsSchedulers, rh,
constraintChecker, profileFunction, activePlugin, context, sp, constraintChecker, profileFunction, activePlugin, context, sp,
config, dateUtil, repository, fabricPrivacy, androidPermission, activityNames, persistenceLayer config, dateUtil, repository, fabricPrivacy, androidPermission, uiInteraction, persistenceLayer
) )
val handler = mock(Handler::class.java) val handler = mock(Handler::class.java)
`when`(handler.post(anyObject())).thenAnswer { invocation: InvocationOnMock -> `when`(handler.post(anyObject())).thenAnswer { invocation: InvocationOnMock ->

View file

@ -17,7 +17,7 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
@ -34,7 +34,7 @@ class QueueThreadTest : TestBaseWithProfile() {
@Mock lateinit var powerManager: PowerManager @Mock lateinit var powerManager: PowerManager
@Mock lateinit var repository: AppRepository @Mock lateinit var repository: AppRepository
@Mock lateinit var androidPermission: AndroidPermission @Mock lateinit var androidPermission: AndroidPermission
@Mock lateinit var activityNames: ActivityNames @Mock lateinit var uiInteraction: UiInteraction
@Mock lateinit var persistenceLayer: PersistenceLayer @Mock lateinit var persistenceLayer: PersistenceLayer
val injector = HasAndroidInjector { val injector = HasAndroidInjector {
@ -60,7 +60,7 @@ class QueueThreadTest : TestBaseWithProfile() {
commandQueue = CommandQueueImplementation( commandQueue = CommandQueueImplementation(
injector, aapsLogger, rxBus, aapsSchedulers, rh, constraintChecker, injector, aapsLogger, rxBus, aapsSchedulers, rh, constraintChecker,
profileFunction, activePlugin, context, sp, profileFunction, activePlugin, context, sp,
config, dateUtil, repository, fabricPrivacy, androidPermission, activityNames, persistenceLayer config, dateUtil, repository, fabricPrivacy, androidPermission, uiInteraction, persistenceLayer
) )
val pumpDescription = PumpDescription() val pumpDescription = PumpDescription()

View file

@ -32,7 +32,7 @@ import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.profile.ProfileInstantiator import info.nightscout.interfaces.profile.ProfileInstantiator
import info.nightscout.interfaces.profile.ProfileStore import info.nightscout.interfaces.profile.ProfileStore
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.MidnightTime import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
import info.nightscout.plugins.aps.R import info.nightscout.plugins.aps.R
@ -69,7 +69,7 @@ class AutotuneFragment : DaggerFragment() {
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
@Inject lateinit var injector: HasAndroidInjector @Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
@Inject lateinit var profileInstantiator: ProfileInstantiator @Inject lateinit var profileInstantiator: ProfileInstantiator
private var disposable: CompositeDisposable = CompositeDisposable() private var disposable: CompositeDisposable = CompositeDisposable()
@ -200,10 +200,10 @@ class AutotuneFragment : DaggerFragment() {
} }
} }
pumpProfile?.let { pumpProfile?.let {
activityNames.runProfileViewerDialog( uiInteraction.runProfileViewerDialog(
fragmentManager = childFragmentManager, fragmentManager = childFragmentManager,
time = dateUtil.now(), time = dateUtil.now(),
mode = ActivityNames.Mode.CUSTOM_PROFILE, mode = UiInteraction.Mode.CUSTOM_PROFILE,
customProfile = pumpProfile.profile.toPureNsJson(dateUtil).toString(), customProfile = pumpProfile.profile.toPureNsJson(dateUtil).toString(),
customProfileName = pumpProfile.profilename customProfileName = pumpProfile.profilename
) )
@ -214,10 +214,10 @@ class AutotuneFragment : DaggerFragment() {
val pumpProfile = autotunePlugin.pumpProfile val pumpProfile = autotunePlugin.pumpProfile
val circadian = sp.getBoolean(R.string.key_autotune_circadian_ic_isf, false) val circadian = sp.getBoolean(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
activityNames.runProfileViewerDialog( uiInteraction.runProfileViewerDialog(
fragmentManager = childFragmentManager, fragmentManager = childFragmentManager,
time = dateUtil.now(), time = dateUtil.now(),
mode = ActivityNames.Mode.PROFILE_COMPARE, mode = UiInteraction.Mode.PROFILE_COMPARE,
customProfile = pumpProfile.profile.toPureNsJson(dateUtil).toString(), customProfile = pumpProfile.profile.toPureNsJson(dateUtil).toString(),
customProfileName = pumpProfile.profilename + "\n" + rh.gs(R.string.autotune_tunedprofile_name), customProfileName = pumpProfile.profilename + "\n" + rh.gs(R.string.autotune_tunedprofile_name),
customProfile2 = tunedProfile?.toPureNsJson(dateUtil).toString() customProfile2 = tunedProfile?.toPureNsJson(dateUtil).toString()

View file

@ -10,14 +10,14 @@ import info.nightscout.core.ui.locale.LocaleHelper
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.protection.ProtectionCheck import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import javax.inject.Inject import javax.inject.Inject
class SingleFragmentActivity : DaggerAppCompatActivityWithResult() { class SingleFragmentActivity : DaggerAppCompatActivityWithResult() {
@Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var protectionCheck: ProtectionCheck @Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
private var plugin: PluginBase? = null private var plugin: PluginBase? = null
@ -45,7 +45,7 @@ class SingleFragmentActivity : DaggerAppCompatActivityWithResult() {
R.id.nav_plugin_preferences -> { R.id.nav_plugin_preferences -> {
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, { protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
val i = Intent(this, activityNames.preferencesActivity) val i = Intent(this, uiInteraction.preferencesActivity)
i.putExtra("id", plugin?.preferencesId) i.putExtra("id", plugin?.preferencesId)
startActivity(i) startActivity(i)
}, null) }, null)

View file

@ -25,7 +25,7 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.protection.ProtectionCheck import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.protection.ProtectionCheck.Protection.PREFERENCES import info.nightscout.interfaces.protection.ProtectionCheck.Protection.PREFERENCES
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventRebuildTabs import info.nightscout.rx.events.EventRebuildTabs
@ -46,7 +46,7 @@ class ConfigBuilderFragment : DaggerFragment() {
@Inject lateinit var protectionCheck: ProtectionCheck @Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var config: Config @Inject lateinit var config: Config
@Inject lateinit var ctx: Context @Inject lateinit var ctx: Context
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
private var disposable: CompositeDisposable = CompositeDisposable() private var disposable: CompositeDisposable = CompositeDisposable()
private val pluginViewHolders = ArrayList<PluginViewHolder>() private val pluginViewHolders = ArrayList<PluginViewHolder>()
@ -65,7 +65,7 @@ class ConfigBuilderFragment : DaggerFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
val parentClass = this.activity?.let { it::class.java } val parentClass = this.activity?.let { it::class.java }
inMenu = parentClass == activityNames.singleFragmentActivity inMenu = parentClass == uiInteraction.singleFragmentActivity
updateProtectedUi() updateProtectedUi()
binding.unlock.setOnClickListener { queryProtection() } binding.unlock.setOnClickListener { queryProtection() }
} }
@ -166,7 +166,7 @@ class ConfigBuilderFragment : DaggerFragment() {
pluginPreferences.setOnClickListener { pluginPreferences.setOnClickListener {
fragment.activity?.let { activity -> fragment.activity?.let { activity ->
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.PREFERENCES, { protectionCheck.queryProtection(activity, ProtectionCheck.Protection.PREFERENCES, {
val i = Intent(ctx, activityNames.preferencesActivity) val i = Intent(ctx, uiInteraction.preferencesActivity)
i.putExtra("id", plugin.preferencesId) i.putExtra("id", plugin.preferencesId)
fragment.startActivity(i) fragment.startActivity(i)
}, null) }, null)

View file

@ -11,7 +11,7 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventNSClientNewLog import info.nightscout.rx.events.EventNSClientNewLog
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -34,7 +34,7 @@ class RunningConfigurationImpl @Inject constructor(
private val rh: ResourceHelper, private val rh: ResourceHelper,
private val rxBus: RxBus, private val rxBus: RxBus,
private val pumpSync: PumpSync, private val pumpSync: PumpSync,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) : RunningConfiguration { ) : RunningConfiguration {
private var counter = 0 private var counter = 0
@ -74,7 +74,7 @@ class RunningConfigurationImpl @Inject constructor(
configuration.version?.let { configuration.version?.let {
rxBus.send(EventNSClientNewLog("VERSION", "Received AndroidAPS version $it")) rxBus.send(EventNSClientNewLog("VERSION", "Received AndroidAPS version $it"))
if (config.VERSION_NAME.startsWith(it).not()) if (config.VERSION_NAME.startsWith(it).not())
activityNames.addNotification(Notification.NSCLIENT_VERSION_DOES_NOT_MATCH, rh.gs(R.string.nsclient_version_does_not_match), Notification.NORMAL) uiInteraction.addNotification(Notification.NSCLIENT_VERSION_DOES_NOT_MATCH, rh.gs(R.string.nsclient_version_does_not_match), Notification.NORMAL)
} }
configuration.insulin?.let { configuration.insulin?.let {
val insulin = Insulin.InsulinType.fromInt(it) val insulin = Insulin.InsulinType.fromInt(it)

View file

@ -47,7 +47,7 @@ import info.nightscout.interfaces.maintenance.PrefsMetadataKey
import info.nightscout.interfaces.maintenance.PrefsStatus import info.nightscout.interfaces.maintenance.PrefsStatus
import info.nightscout.interfaces.protection.PasswordCheck import info.nightscout.interfaces.protection.PasswordCheck
import info.nightscout.interfaces.storage.Storage import info.nightscout.interfaces.storage.Storage
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.userEntry.UserEntryPresentationHelper import info.nightscout.interfaces.userEntry.UserEntryPresentationHelper
import info.nightscout.interfaces.utils.MidnightTime import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -83,7 +83,7 @@ class ImportExportPrefsImpl @Inject constructor(
private val prefFileList: PrefFileListProvider, private val prefFileList: PrefFileListProvider,
private val uel: UserEntryLogger, private val uel: UserEntryLogger,
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) : ImportExportPrefs { ) : ImportExportPrefs {
override fun prefsFileExists(): Boolean { override fun prefsFileExists(): Boolean {
@ -176,8 +176,8 @@ class ImportExportPrefsImpl @Inject constructor(
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)),
R.string.nav_preferences, { R.string.nav_preferences, {
val intent = Intent(activity, activityNames.preferencesActivity).apply { val intent = Intent(activity, uiInteraction.preferencesActivity).apply {
putExtra("id", activityNames.prefGeneral) putExtra("id", uiInteraction.prefGeneral)
} }
activity.startActivity(intent) activity.startActivity(intent)
}) })

View file

@ -25,7 +25,7 @@ import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.protection.ProtectionCheck.Protection.PREFERENCES import info.nightscout.interfaces.protection.ProtectionCheck.Protection.PREFERENCES
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.sync.DataSyncSelector import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HtmlHelper import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -56,7 +56,7 @@ class MaintenanceFragment : DaggerFragment() {
@Inject lateinit var iobCobCalculator: IobCobCalculator @Inject lateinit var iobCobCalculator: IobCobCalculator
@Inject lateinit var overviewData: OverviewData @Inject lateinit var overviewData: OverviewData
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
@Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var activePlugin: ActivePlugin
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
@ -75,7 +75,7 @@ class MaintenanceFragment : DaggerFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
val parentClass = this.activity?.let { it::class.java } val parentClass = this.activity?.let { it::class.java }
inMenu = parentClass == activityNames.singleFragmentActivity inMenu = parentClass == uiInteraction.singleFragmentActivity
updateProtectedUi() updateProtectedUi()
binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() } binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() }
binding.logDelete.setOnClickListener { binding.logDelete.setOnClickListener {

View file

@ -38,7 +38,7 @@ import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.OmnipodDash import info.nightscout.interfaces.pump.OmnipodDash
import info.nightscout.interfaces.pump.OmnipodEros import info.nightscout.interfaces.pump.OmnipodEros
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HardLimits import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventPumpStatusChanged import info.nightscout.rx.events.EventPumpStatusChanged
@ -67,7 +67,7 @@ class SWDefinition @Inject constructor(
private val cryptoUtil: CryptoUtil, private val cryptoUtil: CryptoUtil,
private val config: Config, private val config: Config,
private val hardLimits: HardLimits, private val hardLimits: HardLimits,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) { ) {
lateinit var activity: AppCompatActivity lateinit var activity: AppCompatActivity
@ -353,7 +353,7 @@ class SWDefinition @Inject constructor(
) )
.add(SWButton(injector) .add(SWButton(injector)
.text(R.string.doprofileswitch) .text(R.string.doprofileswitch)
.action { activityNames.runProfileSwitchDialog(activity.supportFragmentManager) }) .action { uiInteraction.runProfileSwitchDialog(activity.supportFragmentManager) })
.validator { profileFunction.getRequestedProfile() != null } .validator { profileFunction.getRequestedProfile() != null }
.visibility { profileFunction.getRequestedProfile() == null } .visibility { profileFunction.getRequestedProfile() == null }

View file

@ -12,7 +12,7 @@ import info.nightscout.configuration.setupwizard.elements.SWItem
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.locale.LocaleHelper.update import info.nightscout.core.ui.locale.LocaleHelper.update
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.events.EventProfileStoreChanged import info.nightscout.rx.events.EventProfileStoreChanged
import info.nightscout.rx.events.EventProfileSwitchChanged import info.nightscout.rx.events.EventProfileSwitchChanged
@ -34,7 +34,7 @@ class SetupWizardActivity : DaggerAppCompatActivityWithResult() {
@Inject lateinit var sp: SP @Inject lateinit var sp: SP
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
private lateinit var screens: List<SWScreen> private lateinit var screens: List<SWScreen>
@ -164,7 +164,7 @@ class SetupWizardActivity : DaggerAppCompatActivityWithResult() {
@Suppress("UNUSED_PARAMETER") @Suppress("UNUSED_PARAMETER")
fun finishSetupWizard(view: View?) { fun finishSetupWizard(view: View?) {
sp.putBoolean(R.string.key_setupwizard_processed, true) sp.putBoolean(R.string.key_setupwizard_processed, true)
val intent = Intent(this, activityNames.mainActivity) val intent = Intent(this, uiInteraction.mainActivity)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(intent) startActivity(intent)
finish() finish()

View file

@ -14,7 +14,7 @@ import info.nightscout.interfaces.ConfigBuilder
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.rx.events.EventConfigBuilderChange import info.nightscout.rx.events.EventConfigBuilderChange
import info.nightscout.rx.events.EventSWUpdate import info.nightscout.rx.events.EventSWUpdate
import javax.inject.Inject import javax.inject.Inject
@ -23,7 +23,7 @@ class SWPlugin(injector: HasAndroidInjector, private val definition: SWDefinitio
@Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var configBuilder: ConfigBuilder @Inject lateinit var configBuilder: ConfigBuilder
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
private var pType: PluginType? = null private var pType: PluginType? = null
private var radioGroup: RadioGroup? = null private var radioGroup: RadioGroup? = null
@ -93,7 +93,7 @@ class SWPlugin(injector: HasAndroidInjector, private val definition: SWDefinitio
private fun addConfiguration(layout: LinearLayout, plugin: PluginBase) { private fun addConfiguration(layout: LinearLayout, plugin: PluginBase) {
if (plugin.preferencesId != -1) { if (plugin.preferencesId != -1) {
fragment = Class.forName(activityNames.myPreferenceFragment.name).newInstance() as Fragment //MyPreferenceFragment() fragment = Class.forName(uiInteraction.myPreferenceFragment.name).newInstance() as Fragment //MyPreferenceFragment()
fragment?.let { fragment?.let {
it.arguments = Bundle().also { it.putInt("id", plugin.preferencesId) } it.arguments = Bundle().also { it.putInt("id", plugin.preferencesId) }
definition.activity.supportFragmentManager.beginTransaction().run { definition.activity.supportFragmentManager.beginTransaction().run {

View file

@ -5,12 +5,12 @@ import android.widget.LinearLayout
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.configuration.setupwizard.SWDefinition import info.nightscout.configuration.setupwizard.SWDefinition
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import javax.inject.Inject import javax.inject.Inject
class SWPreference(injector: HasAndroidInjector, private val definition: SWDefinition) : SWItem(injector, Type.PREFERENCE) { class SWPreference(injector: HasAndroidInjector, private val definition: SWDefinition) : SWItem(injector, Type.PREFERENCE) {
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
private var xml: Int = -1 private var xml: Int = -1
@ -25,7 +25,7 @@ class SWPreference(injector: HasAndroidInjector, private val definition: SWDefin
} }
private fun addConfiguration(layout: LinearLayout, xml: Int) { private fun addConfiguration(layout: LinearLayout, xml: Int) {
(Class.forName(activityNames.myPreferenceFragment.name).newInstance() as Fragment).also { fragment -> (Class.forName(uiInteraction.myPreferenceFragment.name).newInstance() as Fragment).also { fragment ->
fragment.arguments = Bundle().also { it.putInt("id", xml) } fragment.arguments = Bundle().also { it.putInt("id", xml) }
definition.activity.supportFragmentManager.beginTransaction().run { definition.activity.supportFragmentManager.beginTransaction().run {
replace(layout.id, fragment) replace(layout.id, fragment)

View file

@ -54,7 +54,7 @@ import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HardLimits import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.plugins.aps.loop.events.EventLoopSetLastRunGui import info.nightscout.plugins.aps.loop.events.EventLoopSetLastRunGui
@ -105,7 +105,7 @@ class LoopPlugin @Inject constructor(
private val uel: UserEntryLogger, private val uel: UserEntryLogger,
private val repository: AppRepository, private val repository: AppRepository,
private val runningConfiguration: RunningConfiguration, private val runningConfiguration: RunningConfiguration,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) : PluginBase( ) : PluginBase(
PluginDescription() PluginDescription()
.mainType(PluginType.LOOP) .mainType(PluginType.LOOP)
@ -461,14 +461,14 @@ class LoopPlugin @Inject constructor(
private fun presentSuggestion(builder: NotificationCompat.Builder) { private fun presentSuggestion(builder: NotificationCompat.Builder) {
// Creates an explicit intent for an Activity in your app // Creates an explicit intent for an Activity in your app
val resultIntent = Intent(context, activityNames.mainActivity) val resultIntent = Intent(context, uiInteraction.mainActivity)
// The stack builder object will contain an artificial back stack for the // The stack builder object will contain an artificial back stack for the
// started Activity. // started Activity.
// This ensures that navigating backward from the Activity leads out of // This ensures that navigating backward from the Activity leads out of
// your application to the Home screen. // your application to the Home screen.
val stackBuilder = TaskStackBuilder.create(context) val stackBuilder = TaskStackBuilder.create(context)
stackBuilder.addParentStack(activityNames.mainActivity) stackBuilder.addParentStack(uiInteraction.mainActivity)
// Adds the Intent that starts the Activity to the top of the stack // Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent) stackBuilder.addNextIntent(resultIntent)
val resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) val resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
@ -684,7 +684,7 @@ class LoopPlugin @Inject constructor(
commandQueue.tempBasalAbsolute(0.0, durationInMinutes, true, profile, PumpSync.TemporaryBasalType.EMULATED_PUMP_SUSPEND, object : Callback() { commandQueue.tempBasalAbsolute(0.0, durationInMinutes, true, profile, PumpSync.TemporaryBasalType.EMULATED_PUMP_SUSPEND, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
activityNames.runAlarm(result.comment, rh.gs(R.string.temp_basal_delivery_error), R.raw.boluserror) uiInteraction.runAlarm(result.comment, rh.gs(R.string.temp_basal_delivery_error), R.raw.boluserror)
} }
} }
}) })
@ -692,7 +692,7 @@ class LoopPlugin @Inject constructor(
commandQueue.tempBasalPercent(0, durationInMinutes, true, profile, PumpSync.TemporaryBasalType.EMULATED_PUMP_SUSPEND, object : Callback() { commandQueue.tempBasalPercent(0, durationInMinutes, true, profile, PumpSync.TemporaryBasalType.EMULATED_PUMP_SUSPEND, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
activityNames.runAlarm(result.comment, rh.gs(R.string.temp_basal_delivery_error), R.raw.boluserror) uiInteraction.runAlarm(result.comment, rh.gs(R.string.temp_basal_delivery_error), R.raw.boluserror)
} }
} }
}) })
@ -701,7 +701,7 @@ class LoopPlugin @Inject constructor(
commandQueue.cancelExtended(object : Callback() { commandQueue.cancelExtended(object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
activityNames.runAlarm(result.comment, rh.gs(R.string.extendedbolusdeliveryerror), R.raw.boluserror) uiInteraction.runAlarm(result.comment, rh.gs(R.string.extendedbolusdeliveryerror), R.raw.boluserror)
} }
} }
}) })
@ -719,7 +719,7 @@ class LoopPlugin @Inject constructor(
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
activityNames.runAlarm(result.comment, rh.gs(R.string.temp_basal_delivery_error), R.raw.boluserror) uiInteraction.runAlarm(result.comment, rh.gs(R.string.temp_basal_delivery_error), R.raw.boluserror)
} }
} }
}) })

View file

@ -30,7 +30,7 @@ import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.pump.actions.CustomAction import info.nightscout.interfaces.pump.actions.CustomAction
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.plugins.databinding.ActionsFragmentBinding import info.nightscout.plugins.databinding.ActionsFragmentBinding
import info.nightscout.plugins.skins.SkinProvider import info.nightscout.plugins.skins.SkinProvider
@ -72,7 +72,7 @@ class ActionsFragment : DaggerFragment() {
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger
@Inject lateinit var repository: AppRepository @Inject lateinit var repository: AppRepository
@Inject lateinit var loop: Loop @Inject lateinit var loop: Loop
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
private var disposable: CompositeDisposable = CompositeDisposable() private var disposable: CompositeDisposable = CompositeDisposable()
@ -109,7 +109,7 @@ class ActionsFragment : DaggerFragment() {
protectionCheck.queryProtection( protectionCheck.queryProtection(
activity, activity,
ProtectionCheck.Protection.BOLUS, ProtectionCheck.Protection.BOLUS,
UIRunnable { activityNames.runProfileSwitchDialog(childFragmentManager) }) UIRunnable { uiInteraction.runProfileSwitchDialog(childFragmentManager) })
} }
} }
binding.tempTarget.setOnClickListener { binding.tempTarget.setOnClickListener {
@ -117,7 +117,7 @@ class ActionsFragment : DaggerFragment() {
protectionCheck.queryProtection( protectionCheck.queryProtection(
activity, activity,
ProtectionCheck.Protection.BOLUS, ProtectionCheck.Protection.BOLUS,
UIRunnable { activityNames.runTempTargetDialog(childFragmentManager) }) UIRunnable { uiInteraction.runTempTargetDialog(childFragmentManager) })
} }
} }
binding.extendedBolus.setOnClickListener { binding.extendedBolus.setOnClickListener {
@ -126,7 +126,7 @@ class ActionsFragment : DaggerFragment() {
OKDialog.showConfirmation( OKDialog.showConfirmation(
activity, rh.gs(R.string.extended_bolus), rh.gs(R.string.ebstopsloop), activity, rh.gs(R.string.extended_bolus), rh.gs(R.string.ebstopsloop),
Runnable { Runnable {
activityNames.runExtendedBolusDialog(childFragmentManager) uiInteraction.runExtendedBolusDialog(childFragmentManager)
}, null }, null
) )
}) })
@ -138,7 +138,7 @@ class ActionsFragment : DaggerFragment() {
commandQueue.cancelExtended(object : Callback() { commandQueue.cancelExtended(object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
activityNames.runAlarm(result.comment, rh.gs(R.string.extendedbolusdeliveryerror), R.raw.boluserror) uiInteraction.runAlarm(result.comment, rh.gs(R.string.extendedbolusdeliveryerror), R.raw.boluserror)
} }
} }
}) })
@ -149,7 +149,7 @@ class ActionsFragment : DaggerFragment() {
protectionCheck.queryProtection( protectionCheck.queryProtection(
activity, activity,
ProtectionCheck.Protection.BOLUS, ProtectionCheck.Protection.BOLUS,
UIRunnable { activityNames.runTempBasalDialog(childFragmentManager) }) UIRunnable { uiInteraction.runTempBasalDialog(childFragmentManager) })
} }
} }
binding.cancelTempBasal.setOnClickListener { binding.cancelTempBasal.setOnClickListener {
@ -158,7 +158,7 @@ class ActionsFragment : DaggerFragment() {
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
activityNames.runAlarm(result.comment, rh.gs(R.string.temp_basal_delivery_error), R.raw.boluserror) uiInteraction.runAlarm(result.comment, rh.gs(R.string.temp_basal_delivery_error), R.raw.boluserror)
} }
} }
}) })
@ -166,31 +166,31 @@ class ActionsFragment : DaggerFragment() {
} }
binding.fill.setOnClickListener { binding.fill.setOnClickListener {
activity?.let { activity -> activity?.let { activity ->
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { activityNames.runFillDialog(childFragmentManager) }) protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { uiInteraction.runFillDialog(childFragmentManager) })
} }
} }
binding.historyBrowser.setOnClickListener { startActivity(Intent(context, activityNames.historyBrowseActivity)) } binding.historyBrowser.setOnClickListener { startActivity(Intent(context, uiInteraction.historyBrowseActivity)) }
binding.tddStats.setOnClickListener { startActivity(Intent(context, activityNames.tddStatsActivity)) } binding.tddStats.setOnClickListener { startActivity(Intent(context, uiInteraction.tddStatsActivity)) }
binding.bgCheck.setOnClickListener { binding.bgCheck.setOnClickListener {
activityNames.runCareDialog(childFragmentManager, ActivityNames.EventType.BGCHECK, R.string.careportal_bgcheck) uiInteraction.runCareDialog(childFragmentManager, UiInteraction.EventType.BGCHECK, R.string.careportal_bgcheck)
} }
binding.cgmSensorInsert.setOnClickListener { binding.cgmSensorInsert.setOnClickListener {
activityNames.runCareDialog(childFragmentManager, ActivityNames.EventType.SENSOR_INSERT, R.string.cgm_sensor_insert) uiInteraction.runCareDialog(childFragmentManager, UiInteraction.EventType.SENSOR_INSERT, R.string.cgm_sensor_insert)
} }
binding.pumpBatteryChange.setOnClickListener { binding.pumpBatteryChange.setOnClickListener {
activityNames.runCareDialog(childFragmentManager, ActivityNames.EventType.BATTERY_CHANGE, R.string.pump_battery_change) uiInteraction.runCareDialog(childFragmentManager, UiInteraction.EventType.BATTERY_CHANGE, R.string.pump_battery_change)
} }
binding.note.setOnClickListener { binding.note.setOnClickListener {
activityNames.runCareDialog(childFragmentManager, ActivityNames.EventType.NOTE, R.string.careportal_note) uiInteraction.runCareDialog(childFragmentManager, UiInteraction.EventType.NOTE, R.string.careportal_note)
} }
binding.exercise.setOnClickListener { binding.exercise.setOnClickListener {
activityNames.runCareDialog(childFragmentManager, ActivityNames.EventType.EXERCISE, R.string.careportal_exercise) uiInteraction.runCareDialog(childFragmentManager, UiInteraction.EventType.EXERCISE, R.string.careportal_exercise)
} }
binding.question.setOnClickListener { binding.question.setOnClickListener {
activityNames.runCareDialog(childFragmentManager, ActivityNames.EventType.QUESTION, R.string.careportal_question) uiInteraction.runCareDialog(childFragmentManager, UiInteraction.EventType.QUESTION, R.string.careportal_question)
} }
binding.announcement.setOnClickListener { binding.announcement.setOnClickListener {
activityNames.runCareDialog(childFragmentManager, ActivityNames.EventType.ANNOUNCEMENT, R.string.careportal_announcement) uiInteraction.runCareDialog(childFragmentManager, UiInteraction.EventType.ANNOUNCEMENT, R.string.careportal_announcement)
} }
sp.putBoolean(R.string.key_objectiveuseactions, true) sp.putBoolean(R.string.key_objectiveuseactions, true)

View file

@ -22,7 +22,7 @@ import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InvalidateFoodTransaction import info.nightscout.database.impl.transactions.InvalidateFoodTransaction
import info.nightscout.interfaces.logging.UserEntryLogger import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.protection.ProtectionCheck import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.plugins.databinding.FoodFragmentBinding import info.nightscout.plugins.databinding.FoodFragmentBinding
import info.nightscout.plugins.databinding.FoodItemBinding import info.nightscout.plugins.databinding.FoodItemBinding
@ -49,7 +49,7 @@ class FoodFragment : DaggerFragment() {
@Inject lateinit var repository: AppRepository @Inject lateinit var repository: AppRepository
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger
@Inject lateinit var protectionCheck: ProtectionCheck @Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
private var unfiltered: List<Food> = arrayListOf() private var unfiltered: List<Food> = arrayListOf()
@ -224,7 +224,7 @@ class FoodFragment : DaggerFragment() {
val food = v.tag as Food val food = v.tag as Food
activity?.let { activity -> activity?.let { activity ->
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
if (isAdded) activityNames.runWizardDialog(childFragmentManager, food.carbs, food.name) if (isAdded) uiInteraction.runWizardDialog(childFragmentManager, food.carbs, food.name)
}) })
} }
} }

View file

@ -63,7 +63,7 @@ import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.protection.ProtectionCheck import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.TrendCalculator import info.nightscout.interfaces.utils.TrendCalculator
import info.nightscout.plugins.R import info.nightscout.plugins.R
@ -144,7 +144,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
@Inject lateinit var overviewData: OverviewData @Inject lateinit var overviewData: OverviewData
@Inject lateinit var automation: Automation @Inject lateinit var automation: Automation
@Inject lateinit var bgQualityCheck: BgQualityCheck @Inject lateinit var bgQualityCheck: BgQualityCheck
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
@ -367,34 +367,34 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
R.id.treatment_button -> protectionCheck.queryProtection( R.id.treatment_button -> protectionCheck.queryProtection(
activity, activity,
ProtectionCheck.Protection.BOLUS, ProtectionCheck.Protection.BOLUS,
UIRunnable { if (isAdded) activityNames.runTreatmentDialog(childFragmentManager) }) UIRunnable { if (isAdded) uiInteraction.runTreatmentDialog(childFragmentManager) })
R.id.wizard_button -> protectionCheck.queryProtection( R.id.wizard_button -> protectionCheck.queryProtection(
activity, activity,
ProtectionCheck.Protection.BOLUS, ProtectionCheck.Protection.BOLUS,
UIRunnable { if (isAdded) activityNames.runWizardDialog(childFragmentManager) }) UIRunnable { if (isAdded) uiInteraction.runWizardDialog(childFragmentManager) })
R.id.insulin_button -> protectionCheck.queryProtection( R.id.insulin_button -> protectionCheck.queryProtection(
activity, activity,
ProtectionCheck.Protection.BOLUS, ProtectionCheck.Protection.BOLUS,
UIRunnable { if (isAdded) activityNames.runInsulinDialog(childFragmentManager) }) UIRunnable { if (isAdded) uiInteraction.runInsulinDialog(childFragmentManager) })
R.id.quick_wizard_button -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if (isAdded) onClickQuickWizard() }) R.id.quick_wizard_button -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if (isAdded) onClickQuickWizard() })
R.id.carbs_button -> protectionCheck.queryProtection( R.id.carbs_button -> protectionCheck.queryProtection(
activity, activity,
ProtectionCheck.Protection.BOLUS, ProtectionCheck.Protection.BOLUS,
UIRunnable { if (isAdded) activityNames.runCarbsDialog(childFragmentManager) }) UIRunnable { if (isAdded) uiInteraction.runCarbsDialog(childFragmentManager) })
R.id.temp_target -> protectionCheck.queryProtection( R.id.temp_target -> protectionCheck.queryProtection(
activity, activity,
ProtectionCheck.Protection.BOLUS, ProtectionCheck.Protection.BOLUS,
UIRunnable { if (isAdded) activityNames.runTempTargetDialog(childFragmentManager) }) UIRunnable { if (isAdded) uiInteraction.runTempTargetDialog(childFragmentManager) })
R.id.active_profile -> { R.id.active_profile -> {
activityNames.runProfileViewerDialog( uiInteraction.runProfileViewerDialog(
childFragmentManager, childFragmentManager,
dateUtil.now(), dateUtil.now(),
ActivityNames.Mode.RUNNING_PROFILE UiInteraction.Mode.RUNNING_PROFILE
) )
} }
@ -411,7 +411,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
R.id.calibration_button -> { R.id.calibration_button -> {
if (xdripPlugin.isEnabled()) { if (xdripPlugin.isEnabled()) {
activityNames.runCalibrationDialog(childFragmentManager) uiInteraction.runCalibrationDialog(childFragmentManager)
} else if (dexcomPlugin.isEnabled()) { } else if (dexcomPlugin.isEnabled()) {
try { try {
dexcomMediator.findDexcomPackageName()?.let { dexcomMediator.findDexcomPackageName()?.let {
@ -453,7 +453,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
R.id.aps_mode -> { R.id.aps_mode -> {
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
if (isAdded) activityNames.runLoopDialog(childFragmentManager, 1) if (isAdded) uiInteraction.runLoopDialog(childFragmentManager, 1)
}) })
} }
} }
@ -484,7 +484,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
R.id.aps_mode -> { R.id.aps_mode -> {
activity?.let { activity -> activity?.let { activity ->
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
activityNames.runLoopDialog(childFragmentManager, 0) uiInteraction.runLoopDialog(childFragmentManager, 0)
}) })
} }
} }
@ -496,7 +496,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
protectionCheck.queryProtection( protectionCheck.queryProtection(
activity, activity,
ProtectionCheck.Protection.BOLUS, ProtectionCheck.Protection.BOLUS,
UIRunnable { activityNames.runProfileSwitchDialog(childFragmentManager) }) UIRunnable { uiInteraction.runProfileSwitchDialog(childFragmentManager) })
} }
} }

View file

@ -15,7 +15,7 @@ import androidx.recyclerview.widget.RecyclerView
import info.nightscout.interfaces.NotificationHolder import info.nightscout.interfaces.NotificationHolder
import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.ui.IconsProvider import info.nightscout.interfaces.ui.IconsProvider
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.plugins.databinding.OverviewNotificationItemBinding import info.nightscout.plugins.databinding.OverviewNotificationItemBinding
@ -36,7 +36,7 @@ class NotificationStore @Inject constructor(
private val rh: ResourceHelper, private val rh: ResourceHelper,
private val context: Context, private val context: Context,
private val iconsProvider: IconsProvider, private val iconsProvider: IconsProvider,
private val activityNames: ActivityNames, private val uiInteraction: UiInteraction,
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
private val notificationHolder: NotificationHolder, private val notificationHolder: NotificationHolder,
private val activePlugin: ActivePlugin private val activePlugin: ActivePlugin
@ -69,7 +69,7 @@ class NotificationStore @Inject constructor(
store.add(n) store.add(n)
if (sp.getBoolean(R.string.key_raise_notifications_as_android_notifications, true) && n !is NotificationWithAction) if (sp.getBoolean(R.string.key_raise_notifications_as_android_notifications, true) && n !is NotificationWithAction)
raiseSystemNotification(n) raiseSystemNotification(n)
if (n.soundId != null && n.soundId != 0) activityNames.startAlarm(n.soundId!!, n.text) if (n.soundId != null && n.soundId != 0) uiInteraction.startAlarm(n.soundId!!, n.text)
Collections.sort(store, NotificationComparator()) Collections.sort(store, NotificationComparator())
return true return true
} }
@ -78,7 +78,7 @@ class NotificationStore @Inject constructor(
fun remove(id: Int): Boolean { fun remove(id: Int): Boolean {
for (i in store.indices) { for (i in store.indices) {
if (store[i].id == id) { if (store[i].id == id) {
if (store[i].soundId != null) activityNames.stopAlarm("Removed " + store[i].text) if (store[i].soundId != null) uiInteraction.stopAlarm("Removed " + store[i].text)
aapsLogger.debug(LTag.NOTIFICATION, "Notification removed: " + store[i].text) aapsLogger.debug(LTag.NOTIFICATION, "Notification removed: " + store[i].text)
store.removeAt(i) store.removeAt(i)
return true return true
@ -93,7 +93,7 @@ class NotificationStore @Inject constructor(
while (i < store.size) { while (i < store.size) {
val n = store[i] val n = store[i]
if (n.validTo != 0L && n.validTo < System.currentTimeMillis()) { if (n.validTo != 0L && n.validTo < System.currentTimeMillis()) {
if (store[i].soundId != null) activityNames.stopAlarm("Expired " + store[i].text) if (store[i].soundId != null) uiInteraction.stopAlarm("Expired " + store[i].text)
aapsLogger.debug(LTag.NOTIFICATION, "Notification expired: " + store[i].text) aapsLogger.debug(LTag.NOTIFICATION, "Notification expired: " + store[i].text)
store.removeAt(i) store.removeAt(i)
i-- i--

View file

@ -46,7 +46,7 @@ import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HardLimits import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.TrendCalculator import info.nightscout.interfaces.utils.TrendCalculator
@ -101,7 +101,7 @@ class DataHandlerMobile @Inject constructor(
private val activePlugin: ActivePlugin, private val activePlugin: ActivePlugin,
private val commandQueue: CommandQueue, private val commandQueue: CommandQueue,
private val fabricPrivacy: FabricPrivacy, private val fabricPrivacy: FabricPrivacy,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) { ) {
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
@ -293,7 +293,7 @@ class DataHandlerMobile @Inject constructor(
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribe({ .subscribe({
aapsLogger.debug(LTag.WEAR, "SnoozeAlert received $it from ${it.sourceNodeId}") aapsLogger.debug(LTag.WEAR, "SnoozeAlert received $it from ${it.sourceNodeId}")
activityNames.stopAlarm("Muted from wear") uiInteraction.stopAlarm("Muted from wear")
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
disposable += rxBus disposable += rxBus
.toObservable(EventData.WearException::class.java) .toObservable(EventData.WearException::class.java)

View file

@ -22,7 +22,7 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.protection.ProtectionCheck import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HardLimits import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.plugins.R import info.nightscout.plugins.R
@ -57,7 +57,7 @@ class ProfileFragment : DaggerFragment() {
@Inject lateinit var dateUtil: DateUtil @Inject lateinit var dateUtil: DateUtil
@Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
private var disposable: CompositeDisposable = CompositeDisposable() private var disposable: CompositeDisposable = CompositeDisposable()
private var inMenu = false private var inMenu = false
@ -105,7 +105,7 @@ class ProfileFragment : DaggerFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
val parentClass = this.activity?.let { it::class.java } val parentClass = this.activity?.let { it::class.java }
inMenu = parentClass == activityNames.singleFragmentActivity inMenu = parentClass == uiInteraction.singleFragmentActivity
updateProtectedUi() updateProtectedUi()
processVisibility(0) processVisibility(0)
binding.tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { binding.tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
@ -298,7 +298,7 @@ class ProfileFragment : DaggerFragment() {
binding.units.text = rh.gs(R.string.units_colon) + " " + (if (currentProfile.mgdl) rh.gs(R.string.mgdl) else rh.gs(R.string.mmol)) binding.units.text = rh.gs(R.string.units_colon) + " " + (if (currentProfile.mgdl) rh.gs(R.string.mgdl) else rh.gs(R.string.mmol))
binding.profileswitch.setOnClickListener { binding.profileswitch.setOnClickListener {
activityNames.runProfileSwitchDialog(childFragmentManager, profilePlugin.currentProfile()?.name) uiInteraction.runProfileSwitchDialog(childFragmentManager, profilePlugin.currentProfile()?.name)
} }
binding.reset.setOnClickListener { binding.reset.setOnClickListener {

View file

@ -11,7 +11,7 @@ import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.plugins.support.R import info.nightscout.plugins.support.R
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
@ -45,7 +45,7 @@ class SignatureVerifierPlugin @Inject constructor(
rh: ResourceHelper, rh: ResourceHelper,
private val sp: SP, private val sp: SP,
private val context: Context, private val context: Context,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) : PluginBase( ) : PluginBase(
PluginDescription() PluginDescription()
.mainType(PluginType.CONSTRAINTS) .mainType(PluginType.CONSTRAINTS)
@ -103,7 +103,7 @@ class SignatureVerifierPlugin @Inject constructor(
} }
private fun showNotification() { private fun showNotification() {
activityNames.addNotification(Notification.INVALID_VERSION, rh.gs(R.string.running_invalid_version), Notification.URGENT) uiInteraction.addNotification(Notification.INVALID_VERSION, rh.gs(R.string.running_invalid_version), Notification.URGENT)
} }
private fun hasIllegalSignature(): Boolean { private fun hasIllegalSignature(): Boolean {

View file

@ -11,7 +11,7 @@ import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.plugins.support.R import info.nightscout.plugins.support.R
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -25,7 +25,7 @@ class StorageConstraintPlugin @Inject constructor(
injector: HasAndroidInjector, injector: HasAndroidInjector,
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rh: ResourceHelper, rh: ResourceHelper,
private val activeNames: ActivityNames private val activeNames: UiInteraction
) : PluginBase( ) : PluginBase(
PluginDescription() PluginDescription()
.mainType(PluginType.CONSTRAINTS) .mainType(PluginType.CONSTRAINTS)

View file

@ -8,7 +8,7 @@ import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.versionChecker.VersionCheckerUtils import info.nightscout.interfaces.versionChecker.VersionCheckerUtils
import info.nightscout.plugins.support.R import info.nightscout.plugins.support.R
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -31,7 +31,7 @@ class VersionCheckerPlugin @Inject constructor(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
private val config: Config, private val config: Config,
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) : PluginBase( ) : PluginBase(
PluginDescription() PluginDescription()
.mainType(PluginType.CONSTRAINTS) .mainType(PluginType.CONSTRAINTS)
@ -96,7 +96,7 @@ class VersionCheckerPlugin @Inject constructor(
gracePeriod.old, gracePeriod.old,
gracePeriod.veryOld gracePeriod.veryOld
) )
activityNames.addNotification(Notification.OLD_VERSION, message, Notification.NORMAL) uiInteraction.addNotification(Notification.OLD_VERSION, message, Notification.NORMAL)
} }
val endDate = sp.getLong(rh.gs(R.string.key_app_expiration) + "_" + config.VERSION_NAME, 0) val endDate = sp.getLong(rh.gs(R.string.key_app_expiration) + "_" + config.VERSION_NAME, 0)
@ -105,7 +105,7 @@ class VersionCheckerPlugin @Inject constructor(
sp.putLong(R.string.key_last_versionchecker_plugin_warning, now) sp.putLong(R.string.key_last_versionchecker_plugin_warning, now)
//notify //notify
activityNames.addNotification(Notification.VERSION_EXPIRE, rh.gs(R.string.application_expired), Notification.URGENT) uiInteraction.addNotification(Notification.VERSION_EXPIRE, rh.gs(R.string.application_expired), Notification.URGENT)
} }
} }

View file

@ -6,7 +6,7 @@ import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.constraints.versionChecker.AllowedVersions import info.nightscout.interfaces.constraints.versionChecker.AllowedVersions
import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.versionChecker.VersionCheckerUtils import info.nightscout.interfaces.versionChecker.VersionCheckerUtils
import info.nightscout.plugins.support.R import info.nightscout.plugins.support.R
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -29,7 +29,7 @@ class VersionCheckerUtilsImpl @Inject constructor(
private val config: Lazy<Config>, private val config: Lazy<Config>,
private val receiverStatusStore: ReceiverStatusStore, private val receiverStatusStore: ReceiverStatusStore,
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) : VersionCheckerUtils { ) : VersionCheckerUtils {
private fun isConnected(): Boolean = receiverStatusStore.isConnected private fun isConnected(): Boolean = receiverStatusStore.isConnected
@ -121,7 +121,7 @@ class VersionCheckerUtilsImpl @Inject constructor(
val now = dateUtil.now() val now = dateUtil.now()
if (now > sp.getLong(R.string.key_last_versionchecker_warning, 0) + WARN_EVERY) { if (now > sp.getLong(R.string.key_last_versionchecker_warning, 0) + WARN_EVERY) {
aapsLogger.debug(LTag.CORE, "Version $currentVersion outdated. Found $newVersion") aapsLogger.debug(LTag.CORE, "Version $currentVersion outdated. Found $newVersion")
activityNames.addNotification(Notification.NEW_VERSION_DETECTED, rh.gs(R.string.versionavailable, newVersion.toString()), Notification.LOW) uiInteraction.addNotification(Notification.NEW_VERSION_DETECTED, rh.gs(R.string.versionavailable, newVersion.toString()), Notification.LOW)
sp.putLong(R.string.key_last_versionchecker_warning, now) sp.putLong(R.string.key_last_versionchecker_warning, now)
} }
} }
@ -130,7 +130,7 @@ class VersionCheckerUtilsImpl @Inject constructor(
val now = dateUtil.now() val now = dateUtil.now()
if (now > sp.getLong(R.string.key_last_expired_versionchecker_warning, 0) + WARN_EVERY) { if (now > sp.getLong(R.string.key_last_expired_versionchecker_warning, 0) + WARN_EVERY) {
aapsLogger.debug(LTag.CORE, rh.gs(R.string.version_expire, currentVersion, endDate)) aapsLogger.debug(LTag.CORE, rh.gs(R.string.version_expire, currentVersion, endDate))
activityNames.addNotification(Notification.VERSION_EXPIRE, rh.gs(R.string.version_expire, currentVersion, endDate), Notification.LOW) uiInteraction.addNotification(Notification.VERSION_EXPIRE, rh.gs(R.string.version_expire, currentVersion, endDate), Notification.LOW)
sp.putLong(R.string.key_last_expired_versionchecker_warning, now) sp.putLong(R.string.key_last_expired_versionchecker_warning, now)
} }
} }

View file

@ -4,7 +4,7 @@ import android.content.Context
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import org.junit.Assert import org.junit.Assert
@ -16,7 +16,7 @@ class SignatureVerifierPluginTest : TestBase() {
@Mock lateinit var rh: ResourceHelper @Mock lateinit var rh: ResourceHelper
@Mock lateinit var sp: SP @Mock lateinit var sp: SP
@Mock lateinit var context: Context @Mock lateinit var context: Context
@Mock lateinit var activityNames: ActivityNames @Mock lateinit var uiInteraction: UiInteraction
val injector = HasAndroidInjector { AndroidInjector { } } val injector = HasAndroidInjector { AndroidInjector { } }

View file

@ -4,7 +4,7 @@ import dagger.Lazy
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.interfaces.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.versionChecker.VersionCheckerUtils import info.nightscout.interfaces.versionChecker.VersionCheckerUtils
import info.nightscout.plugins.constraints.versionChecker.VersionCheckerUtilsImpl import info.nightscout.plugins.constraints.versionChecker.VersionCheckerUtilsImpl
import info.nightscout.plugins.constraints.versionChecker.numericVersionPart import info.nightscout.plugins.constraints.versionChecker.numericVersionPart
@ -31,10 +31,10 @@ import org.mockito.Mockito.`when`
@Mock lateinit var receiverStatusStore: ReceiverStatusStore @Mock lateinit var receiverStatusStore: ReceiverStatusStore
@Mock lateinit var config: Lazy<Config> @Mock lateinit var config: Lazy<Config>
@Mock lateinit var dateUtil: DateUtil @Mock lateinit var dateUtil: DateUtil
@Mock lateinit var activityNames: ActivityNames @Mock lateinit var uiInteraction: UiInteraction
@Before fun setup() { @Before fun setup() {
versionCheckerUtils = VersionCheckerUtilsImpl(aapsLogger, sp, rh, config, receiverStatusStore, dateUtil, activityNames) versionCheckerUtils = VersionCheckerUtilsImpl(aapsLogger, sp, rh, config, receiverStatusStore, dateUtil, uiInteraction)
} }
@Test @Test
@ -170,49 +170,49 @@ import org.mockito.Mockito.`when`
@Test @Test
fun `should find update1`() { fun `should find update1`() {
versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1") versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
fun `should find update2`() { fun `should find update2`() {
versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1-dev") versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1-dev")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
fun `should find update3`() { fun `should find update3`() {
versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.1") versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.1")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
fun `should find update4`() { fun `should find update4`() {
versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.2", currentVersion = "2.1.1") versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.2", currentVersion = "2.1.1")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
fun `should find update5`() { fun `should find update5`() {
versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2-dev") versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2-dev")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
fun `should find update6`() { fun `should find update6`() {
versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2dev") versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2dev")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
fun `should not find update on fourth version digit`() { fun `should not find update on fourth version digit`() {
versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.5.0", currentVersion = "2.5.0.1") versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.5.0", currentVersion = "2.5.0.1")
verify(activityNames, times(0)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(0)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
fun `should not find update on personal version with same number`() { fun `should not find update on personal version with same number`() {
versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.5.0", currentVersion = "2.5.0-myversion") versionCheckerUtils.compareWithCurrentVersion(newVersion = "2.5.0", currentVersion = "2.5.0-myversion")
verify(activityNames, times(0)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(0)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
@ -226,7 +226,7 @@ import org.mockito.Mockito.`when`
""".trimMargin() """.trimMargin()
versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "2.2.2") versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "2.2.2")
verify(activityNames, times(0)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(0)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
fun `find higher version`() { fun `find higher version`() {
@ -238,7 +238,7 @@ import org.mockito.Mockito.`when`
| appName = "Aaoeu" | appName = "Aaoeu"
""".trimMargin() """.trimMargin()
versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "2.2.2") versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "2.2.2")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
@ -251,7 +251,7 @@ import org.mockito.Mockito.`when`
| appName = "Aaoeu" | appName = "Aaoeu"
""".trimMargin() """.trimMargin()
versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "2.2.2") versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "2.2.2")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
@ -264,7 +264,7 @@ import org.mockito.Mockito.`when`
| appName = "Aaoeu" | appName = "Aaoeu"
""".trimMargin() """.trimMargin()
versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "3.0-RC04") versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "3.0-RC04")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
@ -277,7 +277,7 @@ import org.mockito.Mockito.`when`
| appName = "Aaoeu" | appName = "Aaoeu"
""".trimMargin() """.trimMargin()
versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "3.0RC04") versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "3.0RC04")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
@ -290,7 +290,7 @@ import org.mockito.Mockito.`when`
| appName = "Aaoeu" | appName = "Aaoeu"
""".trimMargin() """.trimMargin()
versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "3.RC04") versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "3.RC04")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
@ -303,7 +303,7 @@ import org.mockito.Mockito.`when`
| appName = "Aaoeu" | appName = "Aaoeu"
""".trimMargin() """.trimMargin()
versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "3.0.RC04") versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "3.0.RC04")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
@ -316,7 +316,7 @@ import org.mockito.Mockito.`when`
| appName = "Aaoeu" | appName = "Aaoeu"
""".trimMargin() """.trimMargin()
versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "3.7.9") versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "3.7.9")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
@ -329,7 +329,7 @@ import org.mockito.Mockito.`when`
| appName = "Aaoeu" | appName = "Aaoeu"
""".trimMargin() """.trimMargin()
versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "2.3") versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "2.3")
verify(activityNames, times(0)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(0)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
@ -342,7 +342,7 @@ import org.mockito.Mockito.`when`
| appName = "Aaoeu" | appName = "Aaoeu"
""".trimMargin() """.trimMargin()
versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "2.3-RC") versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "2.3-RC")
verify(activityNames, times(0)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(0)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
@ -355,7 +355,7 @@ import org.mockito.Mockito.`when`
| appName = "Aaoeu" | appName = "Aaoeu"
""".trimMargin() """.trimMargin()
versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "2.2-beta1") versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "2.2-beta1")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Test @Test
@ -368,7 +368,7 @@ import org.mockito.Mockito.`when`
| appName = "Aaoeu" | appName = "Aaoeu"
""".trimMargin() """.trimMargin()
versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "2.2-rc1") versionCheckerUtils.compareWithCurrentVersion(versionCheckerUtils.findVersion(buildGradle), currentVersion = "2.2-rc1")
verify(activityNames, times(1)).addNotification(anyInt(), anyString(), anyInt()) verify(uiInteraction, times(1)).addNotification(anyInt(), anyString(), anyInt())
} }
@Before @Before

View file

@ -4,7 +4,7 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import org.junit.Assert import org.junit.Assert
@ -18,12 +18,12 @@ import org.mockito.Mockito.`when`
class StorageConstraintPluginTest : TestBase() { class StorageConstraintPluginTest : TestBase() {
@Mock lateinit var rh: ResourceHelper @Mock lateinit var rh: ResourceHelper
@Mock lateinit var activityNames: ActivityNames @Mock lateinit var uiInteraction: UiInteraction
private lateinit var storageConstraintPlugin: StorageConstraintPlugin private lateinit var storageConstraintPlugin: StorageConstraintPlugin
@Before fun prepareMock() { @Before fun prepareMock() {
storageConstraintPlugin = StorageConstraintPlugin({ AndroidInjector { } }, aapsLogger, rh, activityNames) storageConstraintPlugin = StorageConstraintPlugin({ AndroidInjector { } }, aapsLogger, rh, uiInteraction)
`when`(rh.gs(anyInt(), anyLong())).thenReturn("") `when`(rh.gs(anyInt(), anyLong())).thenReturn("")
} }
@ -31,15 +31,15 @@ class StorageConstraintPluginTest : TestBase() {
injector: HasAndroidInjector, injector: HasAndroidInjector,
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rh: ResourceHelper, rh: ResourceHelper,
activityNames: ActivityNames uiInteraction: UiInteraction
) : StorageConstraintPlugin(injector, aapsLogger, rh, activityNames) { ) : StorageConstraintPlugin(injector, aapsLogger, rh, uiInteraction) {
var memSize = 150L var memSize = 150L
override fun availableInternalMemorySize(): Long = memSize override fun availableInternalMemorySize(): Long = memSize
} }
@Test fun isLoopInvocationAllowedTest() { @Test fun isLoopInvocationAllowedTest() {
val mocked = MockedStorageConstraintPlugin({ AndroidInjector { } }, aapsLogger, rh, activityNames) val mocked = MockedStorageConstraintPlugin({ AndroidInjector { } }, aapsLogger, rh, uiInteraction)
// Set free space under 200(Mb) to disable loop // Set free space under 200(Mb) to disable loop
mocked.memSize = 150L mocked.memSize = 150L
Assert.assertEquals(false, mocked.isClosedLoopAllowed(Constraint(true)).value()) Assert.assertEquals(false, mocked.isClosedLoopAllowed(Constraint(true)).value())

View file

@ -39,7 +39,7 @@ import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.nsclient.StoreDataForDb import info.nightscout.interfaces.nsclient.StoreDataForDb
import info.nightscout.interfaces.pump.VirtualPump import info.nightscout.interfaces.pump.VirtualPump
import info.nightscout.interfaces.source.NSClientSource import info.nightscout.interfaces.source.NSClientSource
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.plugins.sync.R import info.nightscout.plugins.sync.R
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventNSClientNewLog import info.nightscout.rx.events.EventNSClientNewLog
@ -73,7 +73,7 @@ class StoreDataForDbImpl @Inject constructor(
private val nsClientSource: NSClientSource, private val nsClientSource: NSClientSource,
private val xDripBroadcast: XDripBroadcast, private val xDripBroadcast: XDripBroadcast,
private val virtualPump: VirtualPump, private val virtualPump: VirtualPump,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) : StoreDataForDb { ) : StoreDataForDb {
override val glucoseValues: MutableList<TransactionGlucoseValue> = mutableListOf() override val glucoseValues: MutableList<TransactionGlucoseValue> = mutableListOf()
@ -529,7 +529,7 @@ class StoreDataForDbImpl @Inject constructor(
it.enteredBy != sp.getString("careportal_enteredby", "AndroidAPS") it.enteredBy != sp.getString("careportal_enteredby", "AndroidAPS")
) { ) {
if (sp.getBoolean(R.string.key_ns_announcements, config.NSCLIENT)) if (sp.getBoolean(R.string.key_ns_announcements, config.NSCLIENT))
activityNames.addNotificationValidFor(Notification.NS_ANNOUNCEMENT, it.note ?: "", Notification.ANNOUNCEMENT, 60) uiInteraction.addNotificationValidFor(Notification.NS_ANNOUNCEMENT, it.note ?: "", Notification.ANNOUNCEMENT, 60)
} }
} }
if (therapyEvents.isNotEmpty()) if (therapyEvents.isNotEmpty())

View file

@ -22,7 +22,7 @@ import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.sync.DataSyncSelector import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.interfaces.sync.NsClient import info.nightscout.interfaces.sync.NsClient
import info.nightscout.interfaces.sync.Sync import info.nightscout.interfaces.sync.Sync
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HtmlHelper.fromHtml import info.nightscout.interfaces.utils.HtmlHelper.fromHtml
import info.nightscout.plugins.sync.R import info.nightscout.plugins.sync.R
import info.nightscout.plugins.sync.nsShared.NSClientFragment import info.nightscout.plugins.sync.nsShared.NSClientFragment
@ -61,7 +61,7 @@ class NSClientPlugin @Inject constructor(
private val nsClientReceiverDelegate: NsClientReceiverDelegate, private val nsClientReceiverDelegate: NsClientReceiverDelegate,
private val config: Config, private val config: Config,
private val dataSyncSelector: DataSyncSelector, private val dataSyncSelector: DataSyncSelector,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) : NsClient, Sync, PluginBase( ) : NsClient, Sync, PluginBase(
PluginDescription() PluginDescription()
.mainType(PluginType.SYNC) .mainType(PluginType.SYNC)
@ -185,7 +185,7 @@ class NSClientPlugin @Inject constructor(
} }
return fromHtml(newTextLog.toString()) return fromHtml(newTextLog.toString())
} catch (e: OutOfMemoryError) { } catch (e: OutOfMemoryError) {
activityNames.showToastAndNotification(context, "Out of memory!\nStop using this phone !!!", R.raw.error) uiInteraction.showToastAndNotification(context, "Out of memory!\nStop using this phone !!!", R.raw.error)
} }
return fromHtml("") return fromHtml("")
} }

View file

@ -10,7 +10,7 @@ import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.nsclient.NSSettingsStatus import info.nightscout.interfaces.nsclient.NSSettingsStatus
import info.nightscout.interfaces.profile.DefaultValueHelper import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.sync.R import info.nightscout.plugins.sync.R
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -124,7 +124,7 @@ class NSSettingsStatusImpl @Inject constructor(
private val sp: SP, private val sp: SP,
private val config: Config, private val config: Config,
private val uel: UserEntryLogger, private val uel: UserEntryLogger,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) : NSSettingsStatus { ) : NSSettingsStatus {
// ***** PUMP STATUS ****** // ***** PUMP STATUS ******
@ -151,7 +151,7 @@ class NSSettingsStatusImpl @Inject constructor(
data = status data = status
aapsLogger.debug(LTag.NSCLIENT, "Got versions: Nightscout: ${getVersion()}") aapsLogger.debug(LTag.NSCLIENT, "Got versions: Nightscout: ${getVersion()}")
if (getVersionNum() < config.SUPPORTEDNSVERSION) { if (getVersionNum() < config.SUPPORTEDNSVERSION) {
activityNames.addNotification(Notification.OLD_NS, rh.gs(R.string.unsupported_ns_version), Notification.NORMAL) uiInteraction.addNotification(Notification.OLD_NS, rh.gs(R.string.unsupported_ns_version), Notification.NORMAL)
} else { } else {
rxBus.send(EventDismissNotification(Notification.OLD_NS)) rxBus.send(EventDismissNotification(Notification.OLD_NS))
} }

View file

@ -26,12 +26,11 @@ import info.nightscout.interfaces.nsclient.NSAlarm
import info.nightscout.interfaces.nsclient.NSSettingsStatus import info.nightscout.interfaces.nsclient.NSSettingsStatus
import info.nightscout.interfaces.sync.DataSyncSelector import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.interfaces.sync.NsClient import info.nightscout.interfaces.sync.NsClient
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.JsonHelper.safeGetString import info.nightscout.interfaces.utils.JsonHelper.safeGetString
import info.nightscout.interfaces.utils.JsonHelper.safeGetStringAllowNull import info.nightscout.interfaces.utils.JsonHelper.safeGetStringAllowNull
import info.nightscout.interfaces.workflow.WorkerClasses import info.nightscout.interfaces.workflow.WorkerClasses
import info.nightscout.plugins.sync.R import info.nightscout.plugins.sync.R
import info.nightscout.interfaces.nsclient.StoreDataForDb
import info.nightscout.plugins.sync.nsShared.StoreDataForDbImpl import info.nightscout.plugins.sync.nsShared.StoreDataForDbImpl
import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus
import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI
@ -90,7 +89,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage @Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var dataSyncSelector: DataSyncSelector @Inject lateinit var dataSyncSelector: DataSyncSelector
@Inject lateinit var repository: AppRepository @Inject lateinit var repository: AppRepository
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
@Inject lateinit var workerClasses: WorkerClasses @Inject lateinit var workerClasses: WorkerClasses
companion object { companion object {
@ -669,7 +668,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
val defaultVal = config.NSCLIENT val defaultVal = config.NSCLIENT
if (sp.getBoolean(R.string.key_ns_announcements, defaultVal)) { if (sp.getBoolean(R.string.key_ns_announcements, defaultVal)) {
val nsAlarm = NSAlarm(announcement) val nsAlarm = NSAlarm(announcement)
activityNames.addNotificationWithAction(injector, nsAlarm) uiInteraction.addNotificationWithAction(injector, nsAlarm)
rxBus.send(EventNSClientNewLog("ANNOUNCEMENT", safeGetString(announcement, "message", "received"))) rxBus.send(EventNSClientNewLog("ANNOUNCEMENT", safeGetString(announcement, "message", "received")))
aapsLogger.debug(LTag.NSCLIENT, announcement.toString()) aapsLogger.debug(LTag.NSCLIENT, announcement.toString())
} }
@ -681,7 +680,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
val snoozedTo = sp.getLong(R.string.key_snoozed_to, 0L) val snoozedTo = sp.getLong(R.string.key_snoozed_to, 0L)
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
val nsAlarm = NSAlarm(alarm) val nsAlarm = NSAlarm(alarm)
activityNames.addNotificationWithAction(injector, nsAlarm) uiInteraction.addNotificationWithAction(injector, nsAlarm)
} }
rxBus.send(EventNSClientNewLog("ALARM", safeGetString(alarm, "message", "received"))) rxBus.send(EventNSClientNewLog("ALARM", safeGetString(alarm, "message", "received")))
aapsLogger.debug(LTag.NSCLIENT, alarm.toString()) aapsLogger.debug(LTag.NSCLIENT, alarm.toString())
@ -694,7 +693,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
val snoozedTo = sp.getLong(R.string.key_snoozed_to, 0L) val snoozedTo = sp.getLong(R.string.key_snoozed_to, 0L)
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
val nsAlarm = NSAlarm(alarm) val nsAlarm = NSAlarm(alarm)
activityNames.addNotificationWithAction(injector, nsAlarm) uiInteraction.addNotificationWithAction(injector, nsAlarm)
} }
rxBus.send(EventNSClientNewLog("URGENTALARM", safeGetString(alarm, "message", "received"))) rxBus.send(EventNSClientNewLog("URGENTALARM", safeGetString(alarm, "message", "received")))
aapsLogger.debug(LTag.NSCLIENT, alarm.toString()) aapsLogger.debug(LTag.NSCLIENT, alarm.toString())

View file

@ -21,7 +21,7 @@ import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.sync.NsClient import info.nightscout.interfaces.sync.NsClient
import info.nightscout.interfaces.sync.Sync import info.nightscout.interfaces.sync.Sync
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HtmlHelper import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.plugins.sync.R import info.nightscout.plugins.sync.R
import info.nightscout.plugins.sync.nsShared.NSClientFragment import info.nightscout.plugins.sync.nsShared.NSClientFragment
@ -71,7 +71,7 @@ class NSClientV3Plugin @Inject constructor(
private val nsClientReceiverDelegate: NsClientReceiverDelegate, private val nsClientReceiverDelegate: NsClientReceiverDelegate,
private val config: Config, private val config: Config,
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) : NsClient, Sync, PluginBase( ) : NsClient, Sync, PluginBase(
PluginDescription() PluginDescription()
.mainType(PluginType.SYNC) .mainType(PluginType.SYNC)
@ -225,7 +225,7 @@ class NSClientV3Plugin @Inject constructor(
} }
return HtmlHelper.fromHtml(newTextLog.toString()) return HtmlHelper.fromHtml(newTextLog.toString())
} catch (e: OutOfMemoryError) { } catch (e: OutOfMemoryError) {
activityNames.showToastAndNotification(context, "Out of memory!\nStop using this phone !!!", R.raw.error) uiInteraction.showToastAndNotification(context, "Out of memory!\nStop using this phone !!!", R.raw.error)
} }
return HtmlHelper.fromHtml("") return HtmlHelper.fromHtml("")
} }

View file

@ -12,7 +12,7 @@ import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.sync.Sync import info.nightscout.interfaces.sync.Sync
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HtmlHelper import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.plugins.sync.R import info.nightscout.plugins.sync.R
import info.nightscout.plugins.sync.tidepool.comm.TidepoolUploader import info.nightscout.plugins.sync.tidepool.comm.TidepoolUploader
@ -51,7 +51,7 @@ class TidepoolPlugin @Inject constructor(
private val sp: SP, private val sp: SP,
private val rateLimit: RateLimit, private val rateLimit: RateLimit,
private val receiverStatusStore: ReceiverStatusStore, private val receiverStatusStore: ReceiverStatusStore,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) : Sync, PluginBase( ) : Sync, PluginBase(
PluginDescription() PluginDescription()
.mainType(PluginType.SYNC) .mainType(PluginType.SYNC)
@ -172,7 +172,7 @@ class TidepoolPlugin @Inject constructor(
} }
textLog = HtmlHelper.fromHtml(newTextLog.toString()) textLog = HtmlHelper.fromHtml(newTextLog.toString())
} catch (e: OutOfMemoryError) { } catch (e: OutOfMemoryError) {
activityNames.showToastAndNotification(context, "Out of memory!\nStop using this phone !!!", R.raw.error) uiInteraction.showToastAndNotification(context, "Out of memory!\nStop using this phone !!!", R.raw.error)
} }
} }

View file

@ -37,7 +37,7 @@ import info.nightscout.interfaces.pump.defs.ManufacturerType;
import info.nightscout.interfaces.pump.defs.PumpDescription; import info.nightscout.interfaces.pump.defs.PumpDescription;
import info.nightscout.interfaces.pump.defs.PumpType; import info.nightscout.interfaces.pump.defs.PumpType;
import info.nightscout.interfaces.queue.CommandQueue; import info.nightscout.interfaces.queue.CommandQueue;
import info.nightscout.interfaces.ui.ActivityNames; import info.nightscout.interfaces.ui.UiInteraction;
import info.nightscout.pump.combo.events.EventComboPumpUpdateGUI; import info.nightscout.pump.combo.events.EventComboPumpUpdateGUI;
import info.nightscout.pump.combo.ruffyscripter.BasalProfile; import info.nightscout.pump.combo.ruffyscripter.BasalProfile;
import info.nightscout.pump.combo.ruffyscripter.BolusProgressReporter; import info.nightscout.pump.combo.ruffyscripter.BolusProgressReporter;
@ -95,7 +95,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
private final PumpSync pumpSync; private final PumpSync pumpSync;
private final DateUtil dateUtil; private final DateUtil dateUtil;
private final RuffyCommands ruffyScripter; private final RuffyCommands ruffyScripter;
private final ActivityNames activityNames; private final UiInteraction uiInteraction;
private final static PumpDescription pumpDescription = new PumpDescription(); private final static PumpDescription pumpDescription = new PumpDescription();
@ -151,7 +151,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
PumpSync pumpSync, PumpSync pumpSync,
DateUtil dateUtil, DateUtil dateUtil,
RuffyScripter ruffyScripter, RuffyScripter ruffyScripter,
ActivityNames activitynames UiInteraction activitynames
) { ) {
super(new PluginDescription() super(new PluginDescription()
.mainType(PluginType.PUMP) .mainType(PluginType.PUMP)
@ -170,7 +170,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
this.pumpSync = pumpSync; this.pumpSync = pumpSync;
this.dateUtil = dateUtil; this.dateUtil = dateUtil;
this.ruffyScripter = ruffyScripter; this.ruffyScripter = ruffyScripter;
this.activityNames = activitynames; this.uiInteraction = activitynames;
pumpDescription.fillFor(PumpType.ACCU_CHEK_COMBO); pumpDescription.fillFor(PumpType.ACCU_CHEK_COMBO);
} }
@ -262,7 +262,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
// note that this should not happen anymore since the queue is present, which // note that this should not happen anymore since the queue is present, which
// issues a READSTATE when starting to issue commands which initializes the pump // issues a READSTATE when starting to issue commands which initializes the pump
getAapsLogger().error("setNewBasalProfile not initialized"); getAapsLogger().error("setNewBasalProfile not initialized");
activityNames.addNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, getRh().gs(R.string.pump_not_initialized_profile_not_set), Notification.URGENT); uiInteraction.addNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, getRh().gs(R.string.pump_not_initialized_profile_not_set), Notification.URGENT);
return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(R.string.pump_not_initialized_profile_not_set); return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(R.string.pump_not_initialized_profile_not_set);
} }
@ -282,7 +282,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
CommandResult setResult = runCommand(getRh().gs(R.string.combo_activity_setting_basal_profile), 2, CommandResult setResult = runCommand(getRh().gs(R.string.combo_activity_setting_basal_profile), 2,
() -> ruffyScripter.setBasalProfile(requestedBasalProfile)); () -> ruffyScripter.setBasalProfile(requestedBasalProfile));
if (!setResult.success) { if (!setResult.success) {
activityNames.addNotification(Notification.FAILED_UPDATE_PROFILE, getRh().gs(R.string.failed_update_basal_profile), Notification.URGENT); uiInteraction.addNotification(Notification.FAILED_UPDATE_PROFILE, getRh().gs(R.string.failed_update_basal_profile), Notification.URGENT);
return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(R.string.failed_update_basal_profile); return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(R.string.failed_update_basal_profile);
} }
@ -292,7 +292,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
rxBus.send(new EventDismissNotification(Notification.FAILED_UPDATE_PROFILE)); rxBus.send(new EventDismissNotification(Notification.FAILED_UPDATE_PROFILE));
//issue success notification //issue success notification
activityNames.addNotificationValidFor(Notification.PROFILE_SET_OK, uiInteraction.addNotificationValidFor(Notification.PROFILE_SET_OK,
getRh().gs(R.string.profile_set_ok), Notification.INFO, 60); getRh().gs(R.string.profile_set_ok), Notification.INFO, 60);
return new PumpEnactResult(getInjector()).success(true).enacted(true); return new PumpEnactResult(getInjector()).success(true).enacted(true);
} }
@ -366,7 +366,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
// trigger a connect, which will update state and check history // trigger a connect, which will update state and check history
CommandResult stateResult = runCommand(null, 1, ruffyScripter::readPumpState); CommandResult stateResult = runCommand(null, 1, ruffyScripter::readPumpState);
if (stateResult.invalidSetup) { if (stateResult.invalidSetup) {
activityNames.addNotification(Notification.COMBO_PUMP_ALARM, uiInteraction.addNotification(Notification.COMBO_PUMP_ALARM,
getRh().gs(R.string.combo_invalid_setup), getRh().gs(R.string.combo_invalid_setup),
Notification.URGENT); Notification.URGENT);
return; return;
@ -383,7 +383,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
} }
if (stateResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) { if (stateResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) {
activityNames.addNotificationWithSound(Notification.COMBO_PUMP_ALARM, uiInteraction.addNotificationWithSound(Notification.COMBO_PUMP_ALARM,
getRh().gs(R.string.combo_force_disabled_notification), getRh().gs(R.string.combo_force_disabled_notification),
Notification.URGENT, R.raw.alarm); Notification.URGENT, R.raw.alarm);
return; return;
@ -406,7 +406,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
long lastBolusTimestamp = recentBoluses.get(0).timestamp; long lastBolusTimestamp = recentBoluses.get(0).timestamp;
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (lastBolusTimestamp < now - 24 * 60 * 60 * 1000 || lastBolusTimestamp > now + 5 * 60 * 1000) { if (lastBolusTimestamp < now - 24 * 60 * 60 * 1000 || lastBolusTimestamp > now + 5 * 60 * 1000) {
activityNames.addNotification(Notification.COMBO_PUMP_ALARM, uiInteraction.addNotification(Notification.COMBO_PUMP_ALARM,
getRh().gs(R.string.combo_check_date), getRh().gs(R.string.combo_check_date),
Notification.URGENT); Notification.URGENT);
} }
@ -606,7 +606,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
// check pump bolus record has a sane timestamp // check pump bolus record has a sane timestamp
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (lastPumpBolus.timestamp < now - 10 * 60 * 1000 || lastPumpBolus.timestamp > now + 10 * 60 * 1000) { if (lastPumpBolus.timestamp < now - 10 * 60 * 1000 || lastPumpBolus.timestamp > now + 10 * 60 * 1000) {
activityNames.addNotification(Notification.COMBO_PUMP_ALARM, uiInteraction.addNotification(Notification.COMBO_PUMP_ALARM,
getRh().gs(R.string.combo_suspious_bolus_time), Notification.URGENT); getRh().gs(R.string.combo_suspious_bolus_time), Notification.URGENT);
} }
@ -675,7 +675,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
} catch (Exception e) { } catch (Exception e) {
getAapsLogger().error("Adding treatment record failed", e); getAapsLogger().error("Adding treatment record failed", e);
if (detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB) { if (detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB) {
activityNames.addNotification(Notification.COMBO_PUMP_ALARM, uiInteraction.addNotification(Notification.COMBO_PUMP_ALARM,
getRh().gs(R.string.combo_error_updating_treatment_record), Notification.URGENT); getRh().gs(R.string.combo_error_updating_treatment_record), Notification.URGENT);
} }
return false; return false;
@ -898,7 +898,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
pump.lastSuccessfulCmdTime = System.currentTimeMillis(); pump.lastSuccessfulCmdTime = System.currentTimeMillis();
if (validBasalRateProfileSelectedOnPump && commandResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) { if (validBasalRateProfileSelectedOnPump && commandResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) {
setValidBasalRateProfileSelectedOnPump(false); setValidBasalRateProfileSelectedOnPump(false);
activityNames.addNotificationWithSound(Notification.COMBO_PUMP_ALARM, uiInteraction.addNotificationWithSound(Notification.COMBO_PUMP_ALARM,
getRh().gs(R.string.combo_force_disabled_notification), getRh().gs(R.string.combo_force_disabled_notification),
Notification.URGENT, R.raw.alarm); Notification.URGENT, R.raw.alarm);
commandQueue.cancelTempBasal(true, null); commandQueue.cancelTempBasal(true, null);
@ -947,7 +947,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
// so update the var with it, so the check routines below can work on it // so update the var with it, so the check routines below can work on it
preCheckResult = alertConfirmationResult; preCheckResult = alertConfirmationResult;
} else if (activeAlert.errorCode != null) { } else if (activeAlert.errorCode != null) {
activityNames.addNotificationValidTo(Notification.COMBO_PUMP_ALARM, dateUtil.now(), uiInteraction.addNotificationValidTo(Notification.COMBO_PUMP_ALARM, dateUtil.now(),
getRh().gs(R.string.combo_is_in_error_state, activeAlert.errorCode, activeAlert.message), Notification.URGENT, 0); getRh().gs(R.string.combo_is_in_error_state, activeAlert.errorCode, activeAlert.message), Notification.URGENT, 0);
return preCheckResult.success(false); return preCheckResult.success(false);
} }
@ -1011,10 +1011,10 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
CommandResult readBasalResult = runCommand(getRh().gs(R.string.combo_actvity_reading_basal_profile), 2, ruffyScripter::readBasalProfile); CommandResult readBasalResult = runCommand(getRh().gs(R.string.combo_actvity_reading_basal_profile), 2, ruffyScripter::readBasalProfile);
if (readBasalResult.success) { if (readBasalResult.success) {
pump.basalProfile = readBasalResult.basalProfile; pump.basalProfile = readBasalResult.basalProfile;
activityNames.addNotification(Notification.COMBO_PUMP_ALARM, uiInteraction.addNotification(Notification.COMBO_PUMP_ALARM,
getRh().gs(R.string.combo_warning_pump_basal_rate_changed), Notification.NORMAL); getRh().gs(R.string.combo_warning_pump_basal_rate_changed), Notification.NORMAL);
} else { } else {
activityNames.addNotification(Notification.COMBO_PUMP_ALARM, uiInteraction.addNotification(Notification.COMBO_PUMP_ALARM,
getRh().gs(R.string.combo_error_failure_reading_changed_basal_rate), Notification.URGENT); getRh().gs(R.string.combo_error_failure_reading_changed_basal_rate), Notification.URGENT);
} }
} }
@ -1029,10 +1029,10 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
// time couldn't be read (e.g. a warning is displayed on the menu , hiding the time field) // time couldn't be read (e.g. a warning is displayed on the menu , hiding the time field)
} else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 10 * 60 * 1000) { } else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 10 * 60 * 1000) {
getAapsLogger().debug(LTag.PUMP, "Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")"); getAapsLogger().debug(LTag.PUMP, "Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")");
activityNames.addNotification(Notification.COMBO_PUMP_ALARM, getRh().gs(R.string.combo_notification_check_time_date), Notification.URGENT); uiInteraction.addNotification(Notification.COMBO_PUMP_ALARM, getRh().gs(R.string.combo_notification_check_time_date), Notification.URGENT);
} else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 3 * 60 * 1000) { } else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 3 * 60 * 1000) {
getAapsLogger().debug(LTag.PUMP, "Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")"); getAapsLogger().debug(LTag.PUMP, "Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")");
activityNames.addNotification(Notification.COMBO_PUMP_ALARM, getRh().gs(R.string.combo_notification_check_time_date), Notification.NORMAL); uiInteraction.addNotification(Notification.COMBO_PUMP_ALARM, getRh().gs(R.string.combo_notification_check_time_date), Notification.NORMAL);
} }
} }
@ -1051,7 +1051,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
} else if (activeAlert.warningCode == PumpWarningCodes.TBR_CANCELLED) { } else if (activeAlert.warningCode == PumpWarningCodes.TBR_CANCELLED) {
text = getRh().gs(R.string.combo_pump_tbr_cancelled_warrning); text = getRh().gs(R.string.combo_pump_tbr_cancelled_warrning);
} }
activityNames.addNotification(Notification.COMBO_PUMP_ALARM, text, Notification.NORMAL); uiInteraction.addNotification(Notification.COMBO_PUMP_ALARM, text, Notification.NORMAL);
} }
private void checkForUnsafeUsage(CommandResult commandResult) { private void checkForUnsafeUsage(CommandResult commandResult) {
@ -1070,7 +1070,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
if (lastViolation > 0) { if (lastViolation > 0) {
lowSuspendOnlyLoopEnforcedUntil = lastViolation + 6 * 60 * 60 * 1000; lowSuspendOnlyLoopEnforcedUntil = lastViolation + 6 * 60 * 60 * 1000;
if (lowSuspendOnlyLoopEnforcedUntil > System.currentTimeMillis() && violationWarningRaisedForBolusAt != lowSuspendOnlyLoopEnforcedUntil) { if (lowSuspendOnlyLoopEnforcedUntil > System.currentTimeMillis() && violationWarningRaisedForBolusAt != lowSuspendOnlyLoopEnforcedUntil) {
activityNames.addNotificationWithSound(Notification.COMBO_PUMP_ALARM, uiInteraction.addNotificationWithSound(Notification.COMBO_PUMP_ALARM,
getRh().gs(R.string.combo_low_suspend_forced_notification), getRh().gs(R.string.combo_low_suspend_forced_notification),
Notification.URGENT, R.raw.alarm); Notification.URGENT, R.raw.alarm);
violationWarningRaisedForBolusAt = lowSuspendOnlyLoopEnforcedUntil; violationWarningRaisedForBolusAt = lowSuspendOnlyLoopEnforcedUntil;
@ -1240,7 +1240,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
HashSet<Bolus> bolusSet = new HashSet<>(historyResult.history.bolusHistory); HashSet<Bolus> bolusSet = new HashSet<>(historyResult.history.bolusHistory);
if (bolusSet.size() != historyResult.history.bolusHistory.size()) { if (bolusSet.size() != historyResult.history.bolusHistory.size()) {
getAapsLogger().debug(LTag.PUMP, "Bolus with same amount within the same minute imported. Only one will make it to the DB."); getAapsLogger().debug(LTag.PUMP, "Bolus with same amount within the same minute imported. Only one will make it to the DB.");
activityNames.addNotification(Notification.COMBO_PUMP_ALARM, getRh().gs(R.string. uiInteraction.addNotification(Notification.COMBO_PUMP_ALARM, getRh().gs(R.string.
combo_error_multiple_boluses_with_identical_timestamp), Notification.URGENT); combo_error_multiple_boluses_with_identical_timestamp), Notification.URGENT);
} }

View file

@ -10,7 +10,7 @@ import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.PumpEnactResult import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.combo.ruffyscripter.RuffyScripter import info.nightscout.pump.combo.ruffyscripter.RuffyScripter
import info.nightscout.pump.combo.ruffyscripter.history.Bolus import info.nightscout.pump.combo.ruffyscripter.history.Bolus
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -33,7 +33,7 @@ class ComboPluginTest : TestBase() {
@Mock lateinit var dateUtil: DateUtil @Mock lateinit var dateUtil: DateUtil
@Mock lateinit var ruffyScripter: RuffyScripter @Mock lateinit var ruffyScripter: RuffyScripter
@Mock lateinit var context: Context @Mock lateinit var context: Context
@Mock lateinit var activityNames: ActivityNames @Mock lateinit var uiInteraction: UiInteraction
private val injector = HasAndroidInjector { private val injector = HasAndroidInjector {
AndroidInjector { AndroidInjector {
@ -49,7 +49,7 @@ class ComboPluginTest : TestBase() {
fun prepareMocks() { fun prepareMocks() {
`when`(rh.gs(R.string.no_valid_basal_rate)).thenReturn("No valid basal rate read from pump") `when`(rh.gs(R.string.no_valid_basal_rate)).thenReturn("No valid basal rate read from pump")
`when`(context.getString(R.string.combo_pump_unsupported_operation)).thenReturn("Requested operation not supported by pump") `when`(context.getString(R.string.combo_pump_unsupported_operation)).thenReturn("Requested operation not supported by pump")
comboPlugin = ComboPlugin(injector, aapsLogger, RxBus(aapsSchedulers, aapsLogger), rh, profileFunction, sp, commandQueue, pumpSync, dateUtil, ruffyScripter, activityNames) comboPlugin = ComboPlugin(injector, aapsLogger, RxBus(aapsSchedulers, aapsLogger), rh, profileFunction, sp, commandQueue, pumpSync, dateUtil, ruffyScripter, uiInteraction)
} }
@Test @Test

View file

@ -41,7 +41,7 @@ import info.nightscout.interfaces.pump.defs.ManufacturerType
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.TimeChangeType import info.nightscout.interfaces.utils.TimeChangeType
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -108,7 +108,7 @@ class ComboV2Plugin @Inject constructor (
private val sp: SP, private val sp: SP,
private val pumpSync: PumpSync, private val pumpSync: PumpSync,
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) : ) :
PumpPluginBase( PumpPluginBase(
PluginDescription() PluginDescription()
@ -540,7 +540,7 @@ class ComboV2Plugin @Inject constructor (
val activeBasalProfileNumber = it.statusFlow.value?.activeBasalProfileNumber val activeBasalProfileNumber = it.statusFlow.value?.activeBasalProfileNumber
aapsLogger.debug(LTag.PUMP, "Active basal profile number: $activeBasalProfileNumber") aapsLogger.debug(LTag.PUMP, "Active basal profile number: $activeBasalProfileNumber")
if ((activeBasalProfileNumber != null) && (activeBasalProfileNumber != 1)) { if ((activeBasalProfileNumber != null) && (activeBasalProfileNumber != 1)) {
activityNames.addNotification( uiInteraction.addNotification(
Notification.COMBO_PUMP_ALARM, Notification.COMBO_PUMP_ALARM,
text = rh.gs(R.string.combov2_incorrect_active_basal_profile, activeBasalProfileNumber), text = rh.gs(R.string.combov2_incorrect_active_basal_profile, activeBasalProfileNumber),
level = Notification.URGENT level = Notification.URGENT
@ -574,7 +574,7 @@ class ComboV2Plugin @Inject constructor (
notifyAboutComboAlert(e.alertScreenContent) notifyAboutComboAlert(e.alertScreenContent)
forciblyDisconnectDueToError = true forciblyDisconnectDueToError = true
} catch (e: Exception) { } catch (e: Exception) {
activityNames.addNotification( uiInteraction.addNotification(
Notification.COMBO_PUMP_ALARM, Notification.COMBO_PUMP_ALARM,
text = rh.gs(R.string.combov2_connection_error, e.message), text = rh.gs(R.string.combov2_connection_error, e.message),
level = Notification.URGENT level = Notification.URGENT
@ -665,7 +665,7 @@ class ComboV2Plugin @Inject constructor (
if (!isInitialized()) { if (!isInitialized()) {
aapsLogger.error(LTag.PUMP, "Cannot set profile since driver is not initialized") aapsLogger.error(LTag.PUMP, "Cannot set profile since driver is not initialized")
activityNames.addNotification( uiInteraction.addNotification(
Notification.PROFILE_NOT_SET_NOT_INITIALIZED, Notification.PROFILE_NOT_SET_NOT_INITIALIZED,
rh.gs(R.string.pump_not_initialized_profile_not_set), rh.gs(R.string.pump_not_initialized_profile_not_set),
Notification.URGENT Notification.URGENT
@ -694,7 +694,7 @@ class ComboV2Plugin @Inject constructor (
activeBasalProfile = requestedBasalProfile activeBasalProfile = requestedBasalProfile
updateBaseBasalRateUI() updateBaseBasalRateUI()
activityNames.addNotificationValidFor( uiInteraction.addNotificationValidFor(
Notification.PROFILE_SET_OK, Notification.PROFILE_SET_OK,
rh.gs(R.string.profile_set_ok), rh.gs(R.string.profile_set_ok),
Notification.INFO, Notification.INFO,
@ -724,7 +724,7 @@ class ComboV2Plugin @Inject constructor (
} catch (e: Exception) { } catch (e: Exception) {
aapsLogger.error("Exception thrown during basal profile update: $e") aapsLogger.error("Exception thrown during basal profile update: $e")
activityNames.addNotification( uiInteraction.addNotification(
Notification.FAILED_UPDATE_PROFILE, Notification.FAILED_UPDATE_PROFILE,
rh.gs(R.string.failed_update_basal_profile), rh.gs(R.string.failed_update_basal_profile),
Notification.URGENT Notification.URGENT
@ -1699,7 +1699,7 @@ class ComboV2Plugin @Inject constructor (
when (event) { when (event) {
is ComboCtlPump.Event.BatteryLow -> { is ComboCtlPump.Event.BatteryLow -> {
activityNames.addNotification( uiInteraction.addNotification(
Notification.COMBO_PUMP_ALARM, Notification.COMBO_PUMP_ALARM,
text = rh.gs(R.string.combov2_battery_low_warning), text = rh.gs(R.string.combov2_battery_low_warning),
level = Notification.NORMAL level = Notification.NORMAL
@ -1707,7 +1707,7 @@ class ComboV2Plugin @Inject constructor (
} }
is ComboCtlPump.Event.ReservoirLow -> { is ComboCtlPump.Event.ReservoirLow -> {
activityNames.addNotification( uiInteraction.addNotification(
Notification.COMBO_PUMP_ALARM, Notification.COMBO_PUMP_ALARM,
text = rh.gs(R.string.combov2_reservoir_low_warning), text = rh.gs(R.string.combov2_reservoir_low_warning),
level = Notification.NORMAL level = Notification.NORMAL
@ -1802,7 +1802,7 @@ class ComboV2Plugin @Inject constructor (
event.remainingTbrDurationInMinutes / 60, event.remainingTbrDurationInMinutes / 60,
event.remainingTbrDurationInMinutes % 60 event.remainingTbrDurationInMinutes % 60
) )
activityNames.addNotification( uiInteraction.addNotification(
Notification.COMBO_UNKNOWN_TBR, Notification.COMBO_UNKNOWN_TBR,
text = rh.gs( text = rh.gs(
R.string.combov2_unknown_tbr_detected, R.string.combov2_unknown_tbr_detected,
@ -1954,7 +1954,7 @@ class ComboV2Plugin @Inject constructor (
// that the Combo is currently suspended, otherwise this // that the Combo is currently suspended, otherwise this
// only shows up in the Combo fragment. // only shows up in the Combo fragment.
if (newState == DriverState.Suspended) { if (newState == DriverState.Suspended) {
activityNames.addNotification( uiInteraction.addNotification(
Notification.COMBO_PUMP_SUSPENDED, Notification.COMBO_PUMP_SUSPENDED,
text = rh.gs(R.string.combov2_pump_is_suspended), text = rh.gs(R.string.combov2_pump_is_suspended),
level = Notification.NORMAL level = Notification.NORMAL
@ -1995,7 +1995,7 @@ class ComboV2Plugin @Inject constructor (
private fun unpairDueToPumpDataError() { private fun unpairDueToPumpDataError() {
disconnectInternal(forceDisconnect = true) disconnectInternal(forceDisconnect = true)
activityNames.addNotificationValidTo( uiInteraction.addNotificationValidTo(
id = Notification.PUMP_ERROR, id = Notification.PUMP_ERROR,
date = dateUtil.now(), date = dateUtil.now(),
text = rh.gs(R.string.combov2_cannot_access_pump_data), text = rh.gs(R.string.combov2_cannot_access_pump_data),
@ -2081,7 +2081,7 @@ class ComboV2Plugin @Inject constructor (
} }
private fun notifyAboutComboAlert(alert: AlertScreenContent) { private fun notifyAboutComboAlert(alert: AlertScreenContent) {
activityNames.addNotification( uiInteraction.addNotification(
Notification.COMBO_PUMP_ALARM, Notification.COMBO_PUMP_ALARM,
text = "${rh.gs(R.string.combov2_combo_alert)}: ${getAlertDescription(alert)}", text = "${rh.gs(R.string.combov2_combo_alert)}: ${getAlertDescription(alert)}",
level = if (alert is AlertScreenContent.Warning) Notification.NORMAL else Notification.URGENT level = if (alert is AlertScreenContent.Warning) Notification.NORMAL else Notification.URGENT

View file

@ -19,7 +19,7 @@ import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.pump.WarnColors import info.nightscout.interfaces.pump.WarnColors
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.userEntry.UserEntryMapper.Action import info.nightscout.interfaces.userEntry.UserEntryMapper.Action
import info.nightscout.interfaces.userEntry.UserEntryMapper.Sources import info.nightscout.interfaces.userEntry.UserEntryMapper.Sources
import info.nightscout.pump.dana.activities.DanaHistoryActivity import info.nightscout.pump.dana.activities.DanaHistoryActivity
@ -58,7 +58,7 @@ class DanaFragment : DaggerFragment() {
@Inject lateinit var dateUtil: DateUtil @Inject lateinit var dateUtil: DateUtil
@Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
private var disposable: CompositeDisposable = CompositeDisposable() private var disposable: CompositeDisposable = CompositeDisposable()
@ -97,15 +97,15 @@ class DanaFragment : DaggerFragment() {
?: return@setOnClickListener ?: return@setOnClickListener
val profileName = danaPump.createConvertedProfile()?.getDefaultProfileName() val profileName = danaPump.createConvertedProfile()?.getDefaultProfileName()
?: return@setOnClickListener ?: return@setOnClickListener
activityNames.runProfileViewerDialog( uiInteraction.runProfileViewerDialog(
fragmentManager = childFragmentManager, fragmentManager = childFragmentManager,
time = dateUtil.now(), time = dateUtil.now(),
mode = ActivityNames.Mode.CUSTOM_PROFILE, mode = UiInteraction.Mode.CUSTOM_PROFILE,
customProfile = profile.toString(), customProfile = profile.toString(),
customProfileName = profileName customProfileName = profileName
) )
} }
binding.stats.setOnClickListener { startActivity(Intent(context, activityNames.tddStatsActivity)) } binding.stats.setOnClickListener { startActivity(Intent(context, uiInteraction.tddStatsActivity)) }
binding.userOptions.setOnClickListener { startActivity(Intent(context, DanaUserOptionsActivity::class.java)) } binding.userOptions.setOnClickListener { startActivity(Intent(context, DanaUserOptionsActivity::class.java)) }
binding.btConnectionLayout.setOnClickListener { binding.btConnectionLayout.setOnClickListener {
aapsLogger.debug(LTag.PUMP, "Clicked connect to pump") aapsLogger.debug(LTag.PUMP, "Clicked connect to pump")

View file

@ -9,7 +9,7 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.dana.R import info.nightscout.pump.dana.R
import info.nightscout.pump.dana.databinding.DanarUserOptionsActivityBinding import info.nightscout.pump.dana.databinding.DanarUserOptionsActivityBinding
@ -37,7 +37,7 @@ class DanaUserOptionsActivity : DaggerAppCompatActivity() {
@Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var commandQueue: CommandQueue @Inject lateinit var commandQueue: CommandQueue
@Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
@ -158,7 +158,7 @@ class DanaUserOptionsActivity : DaggerAppCompatActivity() {
commandQueue.setUserOptions(object : Callback() { commandQueue.setUserOptions(object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
activityNames.runAlarm(result.comment, rh.gs(R.string.pumperror), R.raw.boluserror) uiInteraction.runAlarm(result.comment, rh.gs(R.string.pumperror), R.raw.boluserror)
} }
} }
}) })

View file

@ -20,7 +20,7 @@ import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.PumpSync.TemporaryBasalType import info.nightscout.interfaces.pump.PumpSync.TemporaryBasalType
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.dana.database.DanaHistoryDatabase import info.nightscout.pump.dana.database.DanaHistoryDatabase
@ -56,9 +56,9 @@ class DanaRKoreanPlugin @Inject constructor(
dateUtil: DateUtil, dateUtil: DateUtil,
private val fabricPrivacy: FabricPrivacy, private val fabricPrivacy: FabricPrivacy,
pumpSync: PumpSync, pumpSync: PumpSync,
activityNames: ActivityNames, uiInteraction: UiInteraction,
danaHistoryDatabase: DanaHistoryDatabase danaHistoryDatabase: DanaHistoryDatabase
) : AbstractDanaRPlugin(injector, danaPump, rh, constraintChecker, aapsLogger, aapsSchedulers, commandQueue, rxBus, activePlugin, sp, dateUtil, pumpSync, activityNames, danaHistoryDatabase) { ) : AbstractDanaRPlugin(injector, danaPump, rh, constraintChecker, aapsLogger, aapsSchedulers, commandQueue, rxBus, activePlugin, sp, dateUtil, pumpSync, uiInteraction, danaHistoryDatabase) {
init { init {
pluginDescription.description(R.string.description_pump_dana_r_korean) pluginDescription.description(R.string.description_pump_dana_r_korean)

View file

@ -31,12 +31,12 @@ class MsgInitConnStatusBasic_k(
aapsLogger.debug(LTag.PUMPCOMM, "easyUIMode: $easyUIMode") aapsLogger.debug(LTag.PUMPCOMM, "easyUIMode: $easyUIMode")
aapsLogger.debug(LTag.PUMPCOMM, "Pump password: " + danaPump.password) aapsLogger.debug(LTag.PUMPCOMM, "Pump password: " + danaPump.password)
if (danaPump.isEasyModeEnabled) { if (danaPump.isEasyModeEnabled) {
activityNames.addNotification(Notification.EASY_MODE_ENABLED, rh.gs(R.string.danar_disableeasymode), Notification.URGENT) uiInteraction.addNotification(Notification.EASY_MODE_ENABLED, rh.gs(R.string.danar_disableeasymode), Notification.URGENT)
} else { } else {
rxBus.send(EventDismissNotification(Notification.EASY_MODE_ENABLED)) rxBus.send(EventDismissNotification(Notification.EASY_MODE_ENABLED))
} }
if (!danaPump.isPasswordOK) { if (!danaPump.isPasswordOK) {
activityNames.addNotification(Notification.WRONG_PUMP_PASSWORD, rh.gs(R.string.wrongpumppassword), Notification.URGENT) uiInteraction.addNotification(Notification.WRONG_PUMP_PASSWORD, rh.gs(R.string.wrongpumppassword), Notification.URGENT)
} else { } else {
rxBus.send(EventDismissNotification(Notification.WRONG_PUMP_PASSWORD)) rxBus.send(EventDismissNotification(Notification.WRONG_PUMP_PASSWORD))
} }

View file

@ -31,7 +31,7 @@ class MsgInitConnStatusBolus_k(
aapsLogger.debug(LTag.PUMPCOMM, "Bolus max: " + danaPump.maxBolus) aapsLogger.debug(LTag.PUMPCOMM, "Bolus max: " + danaPump.maxBolus)
aapsLogger.debug(LTag.PUMPCOMM, "Delivery status: $deliveryStatus") aapsLogger.debug(LTag.PUMPCOMM, "Delivery status: $deliveryStatus")
if (!danaPump.isExtendedBolusEnabled) { if (!danaPump.isExtendedBolusEnabled) {
activityNames.addNotification(Notification.EXTENDED_BOLUS_DISABLED, rh.gs(R.string.danar_enableextendedbolus), Notification.URGENT) uiInteraction.addNotification(Notification.EXTENDED_BOLUS_DISABLED, rh.gs(R.string.danar_enableextendedbolus), Notification.URGENT)
} else { } else {
rxBus.send(EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED)) rxBus.send(EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED))
} }

View file

@ -19,7 +19,7 @@ class MsgInitConnStatusTime_k(
override fun handleMessage(bytes: ByteArray) { override fun handleMessage(bytes: ByteArray) {
if (bytes.size - 10 < 10) { if (bytes.size - 10 < 10) {
activityNames.addNotification(Notification.WRONG_DRIVER, rh.gs(R.string.pumpdrivercorrected), Notification.NORMAL) uiInteraction.addNotification(Notification.WRONG_DRIVER, rh.gs(R.string.pumpdrivercorrected), Notification.NORMAL)
danaRKoreanPlugin.disconnect("Wrong Model") danaRKoreanPlugin.disconnect("Wrong Model")
aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected. Switching to export DanaR") aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected. Switching to export DanaR")
danaRKoreanPlugin.setPluginEnabled(PluginType.PUMP, false) danaRKoreanPlugin.setPluginEnabled(PluginType.PUMP, false)

View file

@ -37,7 +37,6 @@ import info.nightscout.androidaps.danar.services.AbstractDanaRExecutionService;
import info.nightscout.interfaces.Constants; import info.nightscout.interfaces.Constants;
import info.nightscout.interfaces.constraints.Constraints; import info.nightscout.interfaces.constraints.Constraints;
import info.nightscout.interfaces.notifications.Notification; import info.nightscout.interfaces.notifications.Notification;
import info.nightscout.interfaces.plugin.ActivePlugin;
import info.nightscout.interfaces.profile.Profile; import info.nightscout.interfaces.profile.Profile;
import info.nightscout.interfaces.profile.ProfileFunction; import info.nightscout.interfaces.profile.ProfileFunction;
import info.nightscout.interfaces.pump.BolusProgressData; import info.nightscout.interfaces.pump.BolusProgressData;
@ -46,7 +45,7 @@ import info.nightscout.interfaces.pump.PumpSync;
import info.nightscout.interfaces.pump.defs.PumpType; import info.nightscout.interfaces.pump.defs.PumpType;
import info.nightscout.interfaces.queue.Command; import info.nightscout.interfaces.queue.Command;
import info.nightscout.interfaces.queue.CommandQueue; import info.nightscout.interfaces.queue.CommandQueue;
import info.nightscout.interfaces.ui.ActivityNames; import info.nightscout.interfaces.ui.UiInteraction;
import info.nightscout.pump.dana.DanaPump; import info.nightscout.pump.dana.DanaPump;
import info.nightscout.pump.dana.events.EventDanaRNewStatus; import info.nightscout.pump.dana.events.EventDanaRNewStatus;
import info.nightscout.rx.bus.RxBus; import info.nightscout.rx.bus.RxBus;
@ -70,7 +69,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
@Inject DanaRKoreanPlugin danaRKoreanPlugin; @Inject DanaRKoreanPlugin danaRKoreanPlugin;
@Inject CommandQueue commandQueue; @Inject CommandQueue commandQueue;
@Inject MessageHashTableRKorean messageHashTableRKorean; @Inject MessageHashTableRKorean messageHashTableRKorean;
@Inject ActivityNames activityNames; @Inject UiInteraction uiInteraction;
@Inject ProfileFunction profileFunction; @Inject ProfileFunction profileFunction;
@Inject PumpSync pumpSync; @Inject PumpSync pumpSync;
@Inject DateUtil dateUtil; @Inject DateUtil dateUtil;
@ -199,7 +198,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
if (danaPump.getDailyTotalUnits() > danaPump.getMaxDailyTotalUnits() * Constants.dailyLimitWarning) { if (danaPump.getDailyTotalUnits() > danaPump.getMaxDailyTotalUnits() * Constants.dailyLimitWarning) {
aapsLogger.debug(LTag.PUMP, "Approaching daily limit: " + danaPump.getDailyTotalUnits() + "/" + danaPump.getMaxDailyTotalUnits()); aapsLogger.debug(LTag.PUMP, "Approaching daily limit: " + danaPump.getDailyTotalUnits() + "/" + danaPump.getMaxDailyTotalUnits());
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
activityNames.addNotification(Notification.APPROACHING_DAILY_LIMIT, rh.gs(R.string.approachingdailylimit), Notification.URGENT); uiInteraction.addNotification(Notification.APPROACHING_DAILY_LIMIT, rh.gs(R.string.approachingdailylimit), Notification.URGENT);
pumpSync.insertAnnouncement(rh.gs(R.string.approachingdailylimit) + ": " + danaPump.getDailyTotalUnits() + "/" + danaPump.getMaxDailyTotalUnits() + "U", null, PumpType.DANA_R_KOREAN, danaRKoreanPlugin.serialNumber()); pumpSync.insertAnnouncement(rh.gs(R.string.approachingdailylimit) + ": " + danaPump.getDailyTotalUnits() + "/" + danaPump.getMaxDailyTotalUnits() + "U", null, PumpType.DANA_R_KOREAN, danaRKoreanPlugin.serialNumber());
lastApproachingDailyLimit = System.currentTimeMillis(); lastApproachingDailyLimit = System.currentTimeMillis();
} }

View file

@ -27,7 +27,7 @@ import info.nightscout.interfaces.pump.PumpSync;
import info.nightscout.interfaces.pump.TemporaryBasalStorage; import info.nightscout.interfaces.pump.TemporaryBasalStorage;
import info.nightscout.interfaces.pump.defs.PumpType; import info.nightscout.interfaces.pump.defs.PumpType;
import info.nightscout.interfaces.queue.CommandQueue; import info.nightscout.interfaces.queue.CommandQueue;
import info.nightscout.interfaces.ui.ActivityNames; import info.nightscout.interfaces.ui.UiInteraction;
import info.nightscout.interfaces.utils.Round; import info.nightscout.interfaces.utils.Round;
import info.nightscout.pump.dana.DanaPump; import info.nightscout.pump.dana.DanaPump;
import info.nightscout.pump.dana.database.DanaHistoryDatabase; import info.nightscout.pump.dana.database.DanaHistoryDatabase;
@ -75,10 +75,10 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
DateUtil dateUtil, DateUtil dateUtil,
FabricPrivacy fabricPrivacy, FabricPrivacy fabricPrivacy,
PumpSync pumpSync, PumpSync pumpSync,
ActivityNames activityNames, UiInteraction uiInteraction,
DanaHistoryDatabase danaHistoryDatabase DanaHistoryDatabase danaHistoryDatabase
) { ) {
super(injector, danaPump, rh, constraintChecker, aapsLogger, aapsSchedulers, commandQueue, rxBus, activePlugin, sp, dateUtil, pumpSync, activityNames, danaHistoryDatabase); super(injector, danaPump, rh, constraintChecker, aapsLogger, aapsSchedulers, commandQueue, rxBus, activePlugin, sp, dateUtil, pumpSync, uiInteraction, danaHistoryDatabase);
this.aapsLogger = aapsLogger; this.aapsLogger = aapsLogger;
this.context = context; this.context = context;
this.rh = rh; this.rh = rh;

View file

@ -25,7 +25,7 @@ class MsgCheckValue_v2(
danaPump.protocol = intFromBuff(bytes, 1, 1) danaPump.protocol = intFromBuff(bytes, 1, 1)
danaPump.productCode = intFromBuff(bytes, 2, 1) danaPump.productCode = intFromBuff(bytes, 2, 1)
if (danaPump.hwModel != DanaPump.EXPORT_MODEL) { if (danaPump.hwModel != DanaPump.EXPORT_MODEL) {
activityNames.addNotification(Notification.WRONG_DRIVER, rh.gs(R.string.pumpdrivercorrected), Notification.NORMAL) uiInteraction.addNotification(Notification.WRONG_DRIVER, rh.gs(R.string.pumpdrivercorrected), Notification.NORMAL)
danaRPlugin.disconnect("Wrong Model") danaRPlugin.disconnect("Wrong Model")
aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected. Switching to Korean DanaR") aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected. Switching to Korean DanaR")
danaRKoreanPlugin.setPluginEnabled(PluginType.PUMP, true) danaRKoreanPlugin.setPluginEnabled(PluginType.PUMP, true)
@ -41,7 +41,7 @@ class MsgCheckValue_v2(
return return
} }
if (danaPump.protocol != 2) { if (danaPump.protocol != 2) {
activityNames.addNotification(Notification.WRONG_DRIVER, rh.gs(R.string.pumpdrivercorrected), Notification.NORMAL) uiInteraction.addNotification(Notification.WRONG_DRIVER, rh.gs(R.string.pumpdrivercorrected), Notification.NORMAL)
danaRKoreanPlugin.disconnect("Wrong Model") danaRKoreanPlugin.disconnect("Wrong Model")
aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected. Switching to non APS DanaR") aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected. Switching to non APS DanaR")
danaRv2Plugin.setPluginEnabled(PluginType.PUMP, false) danaRv2Plugin.setPluginEnabled(PluginType.PUMP, false)

View file

@ -59,7 +59,7 @@ import info.nightscout.interfaces.pump.defs.PumpType;
import info.nightscout.interfaces.queue.Callback; import info.nightscout.interfaces.queue.Callback;
import info.nightscout.interfaces.queue.Command; import info.nightscout.interfaces.queue.Command;
import info.nightscout.interfaces.queue.CommandQueue; import info.nightscout.interfaces.queue.CommandQueue;
import info.nightscout.interfaces.ui.ActivityNames; import info.nightscout.interfaces.ui.UiInteraction;
import info.nightscout.pump.dana.DanaPump; import info.nightscout.pump.dana.DanaPump;
import info.nightscout.pump.dana.events.EventDanaRNewStatus; import info.nightscout.pump.dana.events.EventDanaRNewStatus;
import info.nightscout.rx.bus.RxBus; import info.nightscout.rx.bus.RxBus;
@ -90,7 +90,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
@Inject PumpSync pumpSync; @Inject PumpSync pumpSync;
@Inject SP sp; @Inject SP sp;
@Inject DateUtil dateUtil; @Inject DateUtil dateUtil;
@Inject ActivityNames activityNames; @Inject UiInteraction uiInteraction;
public DanaRv2ExecutionService() { public DanaRv2ExecutionService() {
} }
@ -194,7 +194,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
if (Math.abs(timeDiff) > 60 * 60 * 1.5) { if (Math.abs(timeDiff) > 60 * 60 * 1.5) {
aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds - large difference"); aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds - large difference");
//If time-diff is very large, warn user until we can synchronize history readings properly //If time-diff is very large, warn user until we can synchronize history readings properly
activityNames.runAlarm(rh.gs(R.string.largetimediff), rh.gs(R.string.largetimedifftitle), R.raw.error); uiInteraction.runAlarm(rh.gs(R.string.largetimediff), rh.gs(R.string.largetimedifftitle), R.raw.error);
//deinitialize pump //deinitialize pump
danaPump.reset(); danaPump.reset();
@ -235,7 +235,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
if (danaPump.getDailyTotalUnits() > danaPump.getMaxDailyTotalUnits() * Constants.dailyLimitWarning) { if (danaPump.getDailyTotalUnits() > danaPump.getMaxDailyTotalUnits() * Constants.dailyLimitWarning) {
aapsLogger.debug(LTag.PUMP, "Approaching daily limit: " + danaPump.getDailyTotalUnits() + "/" + danaPump.getMaxDailyTotalUnits()); aapsLogger.debug(LTag.PUMP, "Approaching daily limit: " + danaPump.getDailyTotalUnits() + "/" + danaPump.getMaxDailyTotalUnits());
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
activityNames.addNotification(Notification.APPROACHING_DAILY_LIMIT, rh.gs(R.string.approachingdailylimit), Notification.URGENT); uiInteraction.addNotification(Notification.APPROACHING_DAILY_LIMIT, rh.gs(R.string.approachingdailylimit), Notification.URGENT);
pumpSync.insertAnnouncement(rh.gs(R.string.approachingdailylimit) + ": " + danaPump.getDailyTotalUnits() + "/" + danaPump.getMaxDailyTotalUnits() + "U", null, PumpType.DANA_R_KOREAN, danaRKoreanPlugin.serialNumber()); pumpSync.insertAnnouncement(rh.gs(R.string.approachingdailylimit) + ": " + danaPump.getDailyTotalUnits() + "/" + danaPump.getMaxDailyTotalUnits() + "U", null, PumpType.DANA_R_KOREAN, danaRKoreanPlugin.serialNumber());
lastApproachingDailyLimit = System.currentTimeMillis(); lastApproachingDailyLimit = System.currentTimeMillis();
} }
@ -349,7 +349,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
mSerialIOThread.sendMessage(msgSetHistoryEntry_v2); mSerialIOThread.sendMessage(msgSetHistoryEntry_v2);
danaPump.lastHistoryFetched = Math.min(danaPump.lastHistoryFetched, carbtime - T.Companion.mins(1).msecs()); danaPump.lastHistoryFetched = Math.min(danaPump.lastHistoryFetched, carbtime - T.Companion.mins(1).msecs());
if (!msgSetHistoryEntry_v2.isReceived() || msgSetHistoryEntry_v2.getFailed()) if (!msgSetHistoryEntry_v2.isReceived() || msgSetHistoryEntry_v2.getFailed())
activityNames.runAlarm(rh.gs(R.string.carbs_store_error), rh.gs(R.string.error), R.raw.boluserror); uiInteraction.runAlarm(rh.gs(R.string.carbs_store_error), rh.gs(R.string.error), R.raw.boluserror);
} }
final long bolusStart = System.currentTimeMillis(); final long bolusStart = System.currentTimeMillis();

View file

@ -23,7 +23,7 @@ import info.nightscout.interfaces.pump.PumpSync;
import info.nightscout.interfaces.pump.defs.ManufacturerType; import info.nightscout.interfaces.pump.defs.ManufacturerType;
import info.nightscout.interfaces.pump.defs.PumpDescription; import info.nightscout.interfaces.pump.defs.PumpDescription;
import info.nightscout.interfaces.queue.CommandQueue; import info.nightscout.interfaces.queue.CommandQueue;
import info.nightscout.interfaces.ui.ActivityNames; import info.nightscout.interfaces.ui.UiInteraction;
import info.nightscout.interfaces.utils.DecimalFormatter; import info.nightscout.interfaces.utils.DecimalFormatter;
import info.nightscout.interfaces.utils.Round; import info.nightscout.interfaces.utils.Round;
import info.nightscout.pump.dana.DanaFragment; import info.nightscout.pump.dana.DanaFragment;
@ -62,7 +62,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
protected DateUtil dateUtil; protected DateUtil dateUtil;
protected AapsSchedulers aapsSchedulers; protected AapsSchedulers aapsSchedulers;
protected PumpSync pumpSync; protected PumpSync pumpSync;
protected ActivityNames activityNames; protected UiInteraction uiInteraction;
protected DanaHistoryDatabase danaHistoryDatabase; protected DanaHistoryDatabase danaHistoryDatabase;
protected AbstractDanaRPlugin( protected AbstractDanaRPlugin(
HasAndroidInjector injector, HasAndroidInjector injector,
@ -77,7 +77,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
SP sp, SP sp,
DateUtil dateUtil, DateUtil dateUtil,
PumpSync pumpSync, PumpSync pumpSync,
ActivityNames activityNames, UiInteraction uiInteraction,
DanaHistoryDatabase danaHistoryDatabase DanaHistoryDatabase danaHistoryDatabase
) { ) {
super(new PluginDescription() super(new PluginDescription()
@ -98,7 +98,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
this.dateUtil = dateUtil; this.dateUtil = dateUtil;
this.aapsSchedulers = aapsSchedulers; this.aapsSchedulers = aapsSchedulers;
this.pumpSync = pumpSync; this.pumpSync = pumpSync;
this.activityNames = activityNames; this.uiInteraction = uiInteraction;
this.danaHistoryDatabase = danaHistoryDatabase; this.danaHistoryDatabase = danaHistoryDatabase;
} }
@ -150,19 +150,19 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
} }
if (!isInitialized()) { if (!isInitialized()) {
getAapsLogger().error("setNewBasalProfile not initialized"); getAapsLogger().error("setNewBasalProfile not initialized");
activityNames.addNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, getRh().gs(R.string.pump_not_initialized_profile_not_set), Notification.URGENT); uiInteraction.addNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, getRh().gs(R.string.pump_not_initialized_profile_not_set), Notification.URGENT);
result.comment(R.string.pump_not_initialized_profile_not_set); result.comment(R.string.pump_not_initialized_profile_not_set);
return result; return result;
} else { } else {
rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
} }
if (!sExecutionService.updateBasalsInPump(profile)) { if (!sExecutionService.updateBasalsInPump(profile)) {
activityNames.addNotification(Notification.FAILED_UPDATE_PROFILE, getRh().gs(R.string.failed_update_basal_profile), Notification.URGENT); uiInteraction.addNotification(Notification.FAILED_UPDATE_PROFILE, getRh().gs(R.string.failed_update_basal_profile), Notification.URGENT);
result.comment(R.string.failed_update_basal_profile); result.comment(R.string.failed_update_basal_profile);
} else { } else {
rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
rxBus.send(new EventDismissNotification(Notification.FAILED_UPDATE_PROFILE)); rxBus.send(new EventDismissNotification(Notification.FAILED_UPDATE_PROFILE));
activityNames.addNotificationValidFor(Notification.PROFILE_SET_OK, getRh().gs(R.string.profile_set_ok), Notification.INFO, 60); uiInteraction.addNotificationValidFor(Notification.PROFILE_SET_OK, getRh().gs(R.string.profile_set_ok), Notification.INFO, 60);
result.success(true).enacted(true).comment("OK"); result.success(true).enacted(true).comment("OK");
} }
return result; return result;

View file

@ -23,7 +23,7 @@ import info.nightscout.interfaces.pump.PumpEnactResult;
import info.nightscout.interfaces.pump.PumpSync; import info.nightscout.interfaces.pump.PumpSync;
import info.nightscout.interfaces.pump.defs.PumpType; import info.nightscout.interfaces.pump.defs.PumpType;
import info.nightscout.interfaces.queue.CommandQueue; import info.nightscout.interfaces.queue.CommandQueue;
import info.nightscout.interfaces.ui.ActivityNames; import info.nightscout.interfaces.ui.UiInteraction;
import info.nightscout.interfaces.utils.Round; import info.nightscout.interfaces.utils.Round;
import info.nightscout.pump.dana.DanaPump; import info.nightscout.pump.dana.DanaPump;
import info.nightscout.pump.dana.database.DanaHistoryDatabase; import info.nightscout.pump.dana.database.DanaHistoryDatabase;
@ -65,10 +65,10 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
DateUtil dateUtil, DateUtil dateUtil,
FabricPrivacy fabricPrivacy, FabricPrivacy fabricPrivacy,
PumpSync pumpSync, PumpSync pumpSync,
ActivityNames activityNames, UiInteraction uiInteraction,
DanaHistoryDatabase danaHistoryDatabase DanaHistoryDatabase danaHistoryDatabase
) { ) {
super(injector, danaPump, rh, constraints, aapsLogger, aapsSchedulers, commandQueue, rxBus, activePlugin, sp, dateUtil, pumpSync, activityNames, danaHistoryDatabase); super(injector, danaPump, rh, constraints, aapsLogger, aapsSchedulers, commandQueue, rxBus, activePlugin, sp, dateUtil, pumpSync, uiInteraction, danaHistoryDatabase);
this.aapsLogger = aapsLogger; this.aapsLogger = aapsLogger;
this.context = context; this.context = context;
this.rh = rh; this.rh = rh;

View file

@ -13,7 +13,7 @@ import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.dana.database.DanaHistoryRecordDao import info.nightscout.pump.dana.database.DanaHistoryRecordDao
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -51,7 +51,7 @@ open class MessageBase(injector: HasAndroidInjector) {
@Inject lateinit var constraintChecker: Constraints @Inject lateinit var constraintChecker: Constraints
@Inject lateinit var pumpSync: PumpSync @Inject lateinit var pumpSync: PumpSync
@Inject lateinit var danaHistoryRecordDao: DanaHistoryRecordDao @Inject lateinit var danaHistoryRecordDao: DanaHistoryRecordDao
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
var injector: HasAndroidInjector var injector: HasAndroidInjector
var buffer = ByteArray(512) var buffer = ByteArray(512)

View file

@ -30,7 +30,7 @@ class MsgInitConnStatusBolus(
aapsLogger.debug(LTag.PUMPCOMM, "Bolus increment: " + danaPump.bolusStep) aapsLogger.debug(LTag.PUMPCOMM, "Bolus increment: " + danaPump.bolusStep)
aapsLogger.debug(LTag.PUMPCOMM, "Bolus max: " + danaPump.maxBolus) aapsLogger.debug(LTag.PUMPCOMM, "Bolus max: " + danaPump.maxBolus)
if (!danaPump.isExtendedBolusEnabled) { if (!danaPump.isExtendedBolusEnabled) {
activityNames.addNotification(Notification.EXTENDED_BOLUS_DISABLED, rh.gs(R.string.danar_enableextendedbolus), Notification.URGENT) uiInteraction.addNotification(Notification.EXTENDED_BOLUS_DISABLED, rh.gs(R.string.danar_enableextendedbolus), Notification.URGENT)
} else { } else {
rxBus.send(EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED)) rxBus.send(EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED))
} }

View file

@ -33,7 +33,7 @@ class MsgInitConnStatusOption(
failed = true failed = true
} }
if (!danaPump.isPasswordOK) { if (!danaPump.isPasswordOK) {
activityNames.addNotification(Notification.WRONG_PUMP_PASSWORD, rh.gs(R.string.wrongpumppassword), Notification.URGENT) uiInteraction.addNotification(Notification.WRONG_PUMP_PASSWORD, rh.gs(R.string.wrongpumppassword), Notification.URGENT)
} else { } else {
rxBus.send(EventDismissNotification(Notification.WRONG_PUMP_PASSWORD)) rxBus.send(EventDismissNotification(Notification.WRONG_PUMP_PASSWORD))
} }

View file

@ -18,7 +18,7 @@ class MsgInitConnStatusTime(
override fun handleMessage(bytes: ByteArray) { override fun handleMessage(bytes: ByteArray) {
if (bytes.size - 10 > 7) { if (bytes.size - 10 > 7) {
activityNames.addNotification(Notification.WRONG_DRIVER, rh.gs(R.string.pumpdrivercorrected), Notification.NORMAL) uiInteraction.addNotification(Notification.WRONG_DRIVER, rh.gs(R.string.pumpdrivercorrected), Notification.NORMAL)
danaRPlugin.disconnect("Wrong Model") danaRPlugin.disconnect("Wrong Model")
aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected. Switching to Korean DanaR") aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected. Switching to Korean DanaR")
danaRKoreanPlugin.setPluginEnabled(PluginType.PUMP, true) danaRKoreanPlugin.setPluginEnabled(PluginType.PUMP, true)

View file

@ -26,11 +26,11 @@ class MsgSetBasalProfile(
if (result != 1) { if (result != 1) {
failed = true failed = true
aapsLogger.debug(LTag.PUMPCOMM, "Set basal profile result: $result FAILED!!!") aapsLogger.debug(LTag.PUMPCOMM, "Set basal profile result: $result FAILED!!!")
activityNames.addNotification(Notification.PROFILE_SET_FAILED, rh.gs(R.string.profile_set_failed), Notification.URGENT) uiInteraction.addNotification(Notification.PROFILE_SET_FAILED, rh.gs(R.string.profile_set_failed), Notification.URGENT)
} else { } else {
failed = false failed = false
aapsLogger.debug(LTag.PUMPCOMM, "Set basal profile result: $result") aapsLogger.debug(LTag.PUMPCOMM, "Set basal profile result: $result")
activityNames.addNotificationValidFor(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60) uiInteraction.addNotificationValidFor(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60)
} }
} }
} }

View file

@ -24,11 +24,11 @@ class MsgSetSingleBasalProfile(
if (result != 1) { if (result != 1) {
failed = true failed = true
aapsLogger.debug(LTag.PUMPCOMM, "Set basal profile result: $result FAILED!!!") aapsLogger.debug(LTag.PUMPCOMM, "Set basal profile result: $result FAILED!!!")
activityNames.addNotification(Notification.PROFILE_SET_FAILED, rh.gs(R.string.profile_set_failed), Notification.URGENT) uiInteraction.addNotification(Notification.PROFILE_SET_FAILED, rh.gs(R.string.profile_set_failed), Notification.URGENT)
} else { } else {
failed = false failed = false
aapsLogger.debug(LTag.PUMPCOMM, "Set basal profile result: $result") aapsLogger.debug(LTag.PUMPCOMM, "Set basal profile result: $result")
activityNames.addNotificationValidFor(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60) uiInteraction.addNotificationValidFor(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60)
} }
} }
} }

View file

@ -33,12 +33,12 @@ class MsgSettingMeal(
danaPump.basalStep = 0.01 danaPump.basalStep = 0.01
} }
if (danaPump.basalStep != 0.01) { if (danaPump.basalStep != 0.01) {
activityNames.addNotification(Notification.WRONG_BASAL_STEP, rh.gs(R.string.danar_setbasalstep001), Notification.URGENT) uiInteraction.addNotification(Notification.WRONG_BASAL_STEP, rh.gs(R.string.danar_setbasalstep001), Notification.URGENT)
} else { } else {
rxBus.send(EventDismissNotification(Notification.WRONG_BASAL_STEP)) rxBus.send(EventDismissNotification(Notification.WRONG_BASAL_STEP))
} }
if (danaPump.isConfigUD) { if (danaPump.isConfigUD) {
activityNames.addNotification(Notification.UD_MODE_ENABLED, rh.gs(R.string.danar_switchtouhmode), Notification.URGENT) uiInteraction.addNotification(Notification.UD_MODE_ENABLED, rh.gs(R.string.danar_switchtouhmode), Notification.URGENT)
} else { } else {
rxBus.send(EventDismissNotification(Notification.UD_MODE_ENABLED)) rxBus.send(EventDismissNotification(Notification.UD_MODE_ENABLED))
} }

View file

@ -44,7 +44,7 @@ import info.nightscout.interfaces.plugin.ActivePlugin;
import info.nightscout.interfaces.profile.Profile; import info.nightscout.interfaces.profile.Profile;
import info.nightscout.interfaces.pump.PumpEnactResult; import info.nightscout.interfaces.pump.PumpEnactResult;
import info.nightscout.interfaces.pump.PumpSync; import info.nightscout.interfaces.pump.PumpSync;
import info.nightscout.interfaces.ui.ActivityNames; import info.nightscout.interfaces.ui.UiInteraction;
import info.nightscout.pump.dana.DanaPump; import info.nightscout.pump.dana.DanaPump;
import info.nightscout.pump.dana.comm.RecordTypes; import info.nightscout.pump.dana.comm.RecordTypes;
import info.nightscout.rx.AapsSchedulers; import info.nightscout.rx.AapsSchedulers;
@ -77,7 +77,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
@Inject AapsSchedulers aapsSchedulers; @Inject AapsSchedulers aapsSchedulers;
@Inject PumpSync pumpSync; @Inject PumpSync pumpSync;
@Inject ActivePlugin activePlugin; @Inject ActivePlugin activePlugin;
@Inject ActivityNames activityNames; @Inject UiInteraction uiInteraction;
private final CompositeDisposable disposable = new CompositeDisposable(); private final CompositeDisposable disposable = new CompositeDisposable();
@ -307,7 +307,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
if (pumpState.getTemporaryBasal().getRate() != danaPump.getTempBasalPercent() if (pumpState.getTemporaryBasal().getRate() != danaPump.getTempBasalPercent()
|| Math.abs(pumpState.getTemporaryBasal().getTimestamp() - danaPump.getTempBasalStart()) > 10000 || Math.abs(pumpState.getTemporaryBasal().getTimestamp() - danaPump.getTempBasalStart()) > 10000
) { // Close current temp basal ) { // Close current temp basal
activityNames.addNotification(Notification.UNSUPPORTED_ACTION_IN_PUMP, rh.gs(R.string.unsupported_action_in_pump), Notification.URGENT); uiInteraction.addNotification(Notification.UNSUPPORTED_ACTION_IN_PUMP, rh.gs(R.string.unsupported_action_in_pump), Notification.URGENT);
aapsLogger.error(LTag.PUMP, "Different temporary basal found running AAPS: " + (pumpState.getTemporaryBasal() + " DanaPump " + danaPump.temporaryBasalToString())); aapsLogger.error(LTag.PUMP, "Different temporary basal found running AAPS: " + (pumpState.getTemporaryBasal() + " DanaPump " + danaPump.temporaryBasalToString()));
pumpSync.syncTemporaryBasalWithPumpId( pumpSync.syncTemporaryBasalWithPumpId(
danaPump.getTempBasalStart(), danaPump.getTempBasalStart(),
@ -326,7 +326,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
activePlugin.getActivePump().model(), activePlugin.getActivePump().model(),
activePlugin.getActivePump().serialNumber() activePlugin.getActivePump().serialNumber()
); );
activityNames.addNotification(Notification.UNSUPPORTED_ACTION_IN_PUMP, rh.gs(R.string.unsupported_action_in_pump), Notification.URGENT); uiInteraction.addNotification(Notification.UNSUPPORTED_ACTION_IN_PUMP, rh.gs(R.string.unsupported_action_in_pump), Notification.URGENT);
aapsLogger.error(LTag.PUMP, "Temporary basal should not be running. Sending stop to AAPS"); aapsLogger.error(LTag.PUMP, "Temporary basal should not be running. Sending stop to AAPS");
} }
} else { } else {
@ -340,7 +340,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
activePlugin.getActivePump().model(), activePlugin.getActivePump().model(),
activePlugin.getActivePump().serialNumber() activePlugin.getActivePump().serialNumber()
); );
activityNames.addNotification(Notification.UNSUPPORTED_ACTION_IN_PUMP, rh.gs(R.string.unsupported_action_in_pump), Notification.URGENT); uiInteraction.addNotification(Notification.UNSUPPORTED_ACTION_IN_PUMP, rh.gs(R.string.unsupported_action_in_pump), Notification.URGENT);
aapsLogger.error(LTag.PUMP, "Temporary basal should be running: DanaPump " + danaPump.temporaryBasalToString()); aapsLogger.error(LTag.PUMP, "Temporary basal should be running: DanaPump " + danaPump.temporaryBasalToString());
} }
} }
@ -350,7 +350,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
if (pumpState.getExtendedBolus().getRate() != danaPump.getExtendedBolusAbsoluteRate() if (pumpState.getExtendedBolus().getRate() != danaPump.getExtendedBolusAbsoluteRate()
|| Math.abs(pumpState.getExtendedBolus().getTimestamp() - danaPump.getExtendedBolusStart()) > 10000 || Math.abs(pumpState.getExtendedBolus().getTimestamp() - danaPump.getExtendedBolusStart()) > 10000
) { // Close current extended ) { // Close current extended
activityNames.addNotification(Notification.UNSUPPORTED_ACTION_IN_PUMP, rh.gs(R.string.unsupported_action_in_pump), Notification.URGENT); uiInteraction.addNotification(Notification.UNSUPPORTED_ACTION_IN_PUMP, rh.gs(R.string.unsupported_action_in_pump), Notification.URGENT);
aapsLogger.error(LTag.PUMP, "Different extended bolus found running AAPS: " + (pumpState.getExtendedBolus() + " DanaPump " + danaPump.extendedBolusToString())); aapsLogger.error(LTag.PUMP, "Different extended bolus found running AAPS: " + (pumpState.getExtendedBolus() + " DanaPump " + danaPump.extendedBolusToString()));
pumpSync.syncExtendedBolusWithPumpId( pumpSync.syncExtendedBolusWithPumpId(
danaPump.getExtendedBolusStart(), danaPump.getExtendedBolusStart(),
@ -369,12 +369,12 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
activePlugin.getActivePump().model(), activePlugin.getActivePump().model(),
activePlugin.getActivePump().serialNumber() activePlugin.getActivePump().serialNumber()
); );
activityNames.addNotification(Notification.UNSUPPORTED_ACTION_IN_PUMP, rh.gs(R.string.unsupported_action_in_pump), Notification.URGENT); uiInteraction.addNotification(Notification.UNSUPPORTED_ACTION_IN_PUMP, rh.gs(R.string.unsupported_action_in_pump), Notification.URGENT);
aapsLogger.error(LTag.PUMP, "Extended bolus should not be running. Sending stop to AAPS"); aapsLogger.error(LTag.PUMP, "Extended bolus should not be running. Sending stop to AAPS");
} }
} else { } else {
if (danaPump.isExtendedInProgress()) { // Create new if (danaPump.isExtendedInProgress()) { // Create new
activityNames.addNotification(Notification.UNSUPPORTED_ACTION_IN_PUMP, rh.gs(R.string.unsupported_action_in_pump), Notification.URGENT); uiInteraction.addNotification(Notification.UNSUPPORTED_ACTION_IN_PUMP, rh.gs(R.string.unsupported_action_in_pump), Notification.URGENT);
aapsLogger.error(LTag.PUMP, "Extended bolus should not be running: DanaPump " + danaPump.extendedBolusToString()); aapsLogger.error(LTag.PUMP, "Extended bolus should not be running: DanaPump " + danaPump.extendedBolusToString());
pumpSync.syncExtendedBolusWithPumpId( pumpSync.syncExtendedBolusWithPumpId(
danaPump.getExtendedBolusStart(), danaPump.getExtendedBolusStart(),

View file

@ -203,7 +203,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
if (danaPump.getDailyTotalUnits() > danaPump.getMaxDailyTotalUnits() * Constants.dailyLimitWarning) { if (danaPump.getDailyTotalUnits() > danaPump.getMaxDailyTotalUnits() * Constants.dailyLimitWarning) {
aapsLogger.debug(LTag.PUMP, "Approaching daily limit: " + danaPump.getDailyTotalUnits() + "/" + danaPump.getMaxDailyTotalUnits()); aapsLogger.debug(LTag.PUMP, "Approaching daily limit: " + danaPump.getDailyTotalUnits() + "/" + danaPump.getMaxDailyTotalUnits());
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
activityNames.addNotification(Notification.APPROACHING_DAILY_LIMIT, rh.gs(R.string.approachingdailylimit), Notification.URGENT); uiInteraction.addNotification(Notification.APPROACHING_DAILY_LIMIT, rh.gs(R.string.approachingdailylimit), Notification.URGENT);
pumpSync.insertAnnouncement(rh.gs(R.string.approachingdailylimit) + ": " + danaPump.getDailyTotalUnits() + "/" + danaPump.getMaxDailyTotalUnits() + "U", null, PumpType.DANA_R_KOREAN, danaRKoreanPlugin.serialNumber()); pumpSync.insertAnnouncement(rh.gs(R.string.approachingdailylimit) + ": " + danaPump.getDailyTotalUnits() + "/" + danaPump.getMaxDailyTotalUnits() + "U", null, PumpType.DANA_R_KOREAN, danaRKoreanPlugin.serialNumber());
lastApproachingDailyLimit = System.currentTimeMillis(); lastApproachingDailyLimit = System.currentTimeMillis();
} }

View file

@ -12,7 +12,7 @@ import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.ProfileInstantiator import info.nightscout.interfaces.profile.ProfileInstantiator
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.dana.database.DanaHistoryDatabase import info.nightscout.pump.dana.database.DanaHistoryDatabase
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
@ -29,7 +29,7 @@ class DanaRPluginTest : TestBaseWithProfile() {
@Mock lateinit var commandQueue: CommandQueue @Mock lateinit var commandQueue: CommandQueue
@Mock lateinit var pumpSync: PumpSync @Mock lateinit var pumpSync: PumpSync
@Mock lateinit var profileInstantiator: ProfileInstantiator @Mock lateinit var profileInstantiator: ProfileInstantiator
@Mock lateinit var activityNames: ActivityNames @Mock lateinit var uiInteraction: UiInteraction
@Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase @Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase
lateinit var danaPump: DanaPump lateinit var danaPump: DanaPump
@ -49,7 +49,7 @@ class DanaRPluginTest : TestBaseWithProfile() {
`when`(rh.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s") `when`(rh.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator) danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync, danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync,
activityNames, danaHistoryDatabase) uiInteraction, danaHistoryDatabase)
} }
@Test @Throws(Exception::class) @Test @Throws(Exception::class)

View file

@ -16,7 +16,7 @@ import info.nightscout.interfaces.profile.ProfileInstantiator
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.dana.database.DanaHistoryRecordDao import info.nightscout.pump.dana.database.DanaHistoryRecordDao
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -47,7 +47,7 @@ open class DanaRTestBase : TestBase() {
@Mock lateinit var pumpSync: PumpSync @Mock lateinit var pumpSync: PumpSync
@Mock lateinit var danaHistoryRecordDao: DanaHistoryRecordDao @Mock lateinit var danaHistoryRecordDao: DanaHistoryRecordDao
@Mock lateinit var profileInstantiator: ProfileInstantiator @Mock lateinit var profileInstantiator: ProfileInstantiator
@Mock lateinit var activityNames: ActivityNames @Mock lateinit var uiInteraction: UiInteraction
private lateinit var testPumpPlugin: TestPumpPlugin private lateinit var testPumpPlugin: TestPumpPlugin
@ -79,7 +79,7 @@ open class DanaRTestBase : TestBase() {
it.commandQueue = commandQueue it.commandQueue = commandQueue
it.pumpSync = pumpSync it.pumpSync = pumpSync
it.danaHistoryRecordDao = danaHistoryRecordDao it.danaHistoryRecordDao = danaHistoryRecordDao
it.activityNames = activityNames it.uiInteraction = uiInteraction
} }
} }
} }

View file

@ -12,7 +12,7 @@ import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.ProfileInstantiator import info.nightscout.interfaces.profile.ProfileInstantiator
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.dana.database.DanaHistoryDatabase import info.nightscout.pump.dana.database.DanaHistoryDatabase
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
@ -29,7 +29,7 @@ class DanaRKoreanPluginTest : TestBaseWithProfile() {
@Mock lateinit var commandQueue: CommandQueue @Mock lateinit var commandQueue: CommandQueue
@Mock lateinit var pumpSync: PumpSync @Mock lateinit var pumpSync: PumpSync
@Mock lateinit var profileInstantiator: ProfileInstantiator @Mock lateinit var profileInstantiator: ProfileInstantiator
@Mock lateinit var activityNames: ActivityNames @Mock lateinit var uiInteraction: UiInteraction
@Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase @Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase
lateinit var danaPump: DanaPump lateinit var danaPump: DanaPump
@ -49,7 +49,7 @@ class DanaRKoreanPluginTest : TestBaseWithProfile() {
`when`(rh.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s") `when`(rh.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator) danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
danaRPlugin = DanaRKoreanPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, danaRPlugin = DanaRKoreanPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy,
pumpSync, activityNames, danaHistoryDatabase) pumpSync, uiInteraction, danaHistoryDatabase)
} }
@Test @Throws(Exception::class) @Test @Throws(Exception::class)

View file

@ -14,7 +14,7 @@ import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.dana.database.DanaHistoryDatabase import info.nightscout.pump.dana.database.DanaHistoryDatabase
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
@ -32,7 +32,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() {
@Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage @Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage
@Mock lateinit var pumpSync: PumpSync @Mock lateinit var pumpSync: PumpSync
@Mock lateinit var profileInstantiator: ProfileInstantiator @Mock lateinit var profileInstantiator: ProfileInstantiator
@Mock lateinit var activityNames: ActivityNames @Mock lateinit var uiInteraction: UiInteraction
@Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase @Mock lateinit var danaHistoryDatabase: DanaHistoryDatabase
lateinit var danaPump: DanaPump lateinit var danaPump: DanaPump
@ -52,7 +52,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() {
`when`(rh.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s") `when`(rh.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator) danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
danaRv2Plugin = DanaRv2Plugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, danaRv2Plugin = DanaRv2Plugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage,
temporaryBasalStorage, dateUtil, fabricPrivacy, pumpSync, activityNames, danaHistoryDatabase) temporaryBasalStorage, dateUtil, fabricPrivacy, pumpSync, uiInteraction, danaHistoryDatabase)
} }
@Test @Test

View file

@ -30,7 +30,7 @@ import info.nightscout.interfaces.pump.defs.ManufacturerType
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
import info.nightscout.pump.dana.DanaFragment import info.nightscout.pump.dana.DanaFragment
@ -78,7 +78,7 @@ class DanaRSPlugin @Inject constructor(
private val temporaryBasalStorage: TemporaryBasalStorage, private val temporaryBasalStorage: TemporaryBasalStorage,
private val fabricPrivacy: FabricPrivacy, private val fabricPrivacy: FabricPrivacy,
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
private val activityNames: ActivityNames, private val uiInteraction: UiInteraction,
private val danaHistoryDatabase: DanaHistoryDatabase private val danaHistoryDatabase: DanaHistoryDatabase
) : PumpPluginBase( ) : PumpPluginBase(
PluginDescription() PluginDescription()
@ -233,20 +233,20 @@ class DanaRSPlugin @Inject constructor(
val result = PumpEnactResult(injector) val result = PumpEnactResult(injector)
if (!isInitialized()) { if (!isInitialized()) {
aapsLogger.error("setNewBasalProfile not initialized") aapsLogger.error("setNewBasalProfile not initialized")
activityNames.addNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, rh.gs(R.string.pump_not_initialized_profile_not_set), Notification.URGENT) uiInteraction.addNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, rh.gs(R.string.pump_not_initialized_profile_not_set), Notification.URGENT)
result.comment = rh.gs(R.string.pump_not_initialized_profile_not_set) result.comment = rh.gs(R.string.pump_not_initialized_profile_not_set)
return result return result
} else { } else {
rxBus.send(EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)) rxBus.send(EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED))
} }
return if (danaRSService?.updateBasalsInPump(profile) != true) { return if (danaRSService?.updateBasalsInPump(profile) != true) {
activityNames.addNotification(Notification.FAILED_UPDATE_PROFILE, rh.gs(R.string.failed_update_basal_profile), Notification.URGENT) uiInteraction.addNotification(Notification.FAILED_UPDATE_PROFILE, rh.gs(R.string.failed_update_basal_profile), Notification.URGENT)
result.comment = rh.gs(R.string.failed_update_basal_profile) result.comment = rh.gs(R.string.failed_update_basal_profile)
result result
} else { } else {
rxBus.send(EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)) rxBus.send(EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED))
rxBus.send(EventDismissNotification(Notification.FAILED_UPDATE_PROFILE)) rxBus.send(EventDismissNotification(Notification.FAILED_UPDATE_PROFILE))
activityNames.addNotificationValidFor(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60) uiInteraction.addNotificationValidFor(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60)
result.success = true result.success = true
result.enacted = true result.enacted = true
result.comment = "OK" result.comment = "OK"

View file

@ -2,7 +2,7 @@ package info.nightscout.pump.danars.comm
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.danars.encryption.BleEncryption import info.nightscout.androidaps.danars.encryption.BleEncryption
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import org.joda.time.DateTime import org.joda.time.DateTime
@ -14,7 +14,7 @@ open class DanaRSPacket(protected var injector: HasAndroidInjector) {
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var dateUtil: DateUtil @Inject lateinit var dateUtil: DateUtil
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
var isReceived = false var isReceived = false
private set private set

View file

@ -47,7 +47,7 @@ class DanaRSPacketBasalGetBasalRate(
aapsLogger.debug(LTag.PUMPCOMM, "Basal " + String.format(Locale.ENGLISH, "%02d", index) + "h: " + danaPump.pumpProfiles!![danaPump.activeProfile][index]) aapsLogger.debug(LTag.PUMPCOMM, "Basal " + String.format(Locale.ENGLISH, "%02d", index) + "h: " + danaPump.pumpProfiles!![danaPump.activeProfile][index])
if (danaPump.basalStep != 0.01) { if (danaPump.basalStep != 0.01) {
failed = true failed = true
activityNames.addNotification(Notification.WRONG_BASAL_STEP, rh.gs(R.string.danar_setbasalstep001), Notification.URGENT) uiInteraction.addNotification(Notification.WRONG_BASAL_STEP, rh.gs(R.string.danar_setbasalstep001), Notification.URGENT)
} else { } else {
rxBus.send(EventDismissNotification(Notification.WRONG_BASAL_STEP)) rxBus.send(EventDismissNotification(Notification.WRONG_BASAL_STEP))
} }

View file

@ -83,7 +83,7 @@ class DanaRSPacketBolusGetBolusOption(
dataSize = 1 dataSize = 1
val missedBolus04EndMin = byteArrayToInt(getBytes(data, dataIndex, dataSize)) val missedBolus04EndMin = byteArrayToInt(getBytes(data, dataIndex, dataSize))
if (!danaPump.isExtendedBolusEnabled) { if (!danaPump.isExtendedBolusEnabled) {
activityNames.addNotification(Notification.EXTENDED_BOLUS_DISABLED, rh.gs(R.string.danar_enableextendedbolus), Notification.URGENT) uiInteraction.addNotification(Notification.EXTENDED_BOLUS_DISABLED, rh.gs(R.string.danar_enableextendedbolus), Notification.URGENT)
failed = true failed = true
} else { } else {
rxBus.send(EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED)) rxBus.send(EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED))

View file

@ -42,7 +42,7 @@ class DanaRSPacketGeneralGetPumpCheck(
aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaPump.protocol)) aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaPump.protocol))
aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaPump.productCode)) aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaPump.productCode))
if (danaPump.productCode < 2) { if (danaPump.productCode < 2) {
activityNames.addNotification(Notification.UNSUPPORTED_FIRMWARE, rh.gs(R.string.unsupportedfirmware), Notification.URGENT) uiInteraction.addNotification(Notification.UNSUPPORTED_FIRMWARE, rh.gs(R.string.unsupportedfirmware), Notification.URGENT)
} }
} }

View file

@ -63,7 +63,7 @@ class DanaRSPacketNotifyAlarm(
aapsLogger.debug(LTag.PUMPCOMM, "Error detected: $errorString") aapsLogger.debug(LTag.PUMPCOMM, "Error detected: $errorString")
return return
} }
activityNames.addNotification(Notification.USER_MESSAGE, errorString, Notification.URGENT) uiInteraction.addNotification(Notification.USER_MESSAGE, errorString, Notification.URGENT)
pumpSync.insertAnnouncement(errorString, null, danaPump.pumpType(), danaPump.serialNumber) pumpSync.insertAnnouncement(errorString, null, danaPump.pumpType(), danaPump.serialNumber)
} }

View file

@ -25,7 +25,7 @@ import info.nightscout.core.utils.notify
import info.nightscout.core.utils.waitMillis import info.nightscout.core.utils.waitMillis
import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.danars.R import info.nightscout.pump.danars.R
import info.nightscout.pump.danars.activities.EnterPinActivity import info.nightscout.pump.danars.activities.EnterPinActivity
@ -63,7 +63,7 @@ class BLEComm @Inject internal constructor(
private val bleEncryption: BleEncryption, private val bleEncryption: BleEncryption,
private val pumpSync: PumpSync, private val pumpSync: PumpSync,
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) { ) {
companion object { companion object {
@ -514,7 +514,7 @@ class BLEComm @Inject internal constructor(
private fun sendConnect() { private fun sendConnect() {
val deviceName = connectDeviceName val deviceName = connectDeviceName
if (deviceName == null || deviceName == "") { if (deviceName == null || deviceName == "") {
activityNames.addNotification(Notification.DEVICE_NOT_PAIRED, rh.gs(R.string.pairfirst), Notification.URGENT) uiInteraction.addNotification(Notification.DEVICE_NOT_PAIRED, rh.gs(R.string.pairfirst), Notification.URGENT)
return return
} }
val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, deviceName) val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, deviceName)
@ -586,7 +586,7 @@ class BLEComm @Inject internal constructor(
mSendQueue.clear() mSendQueue.clear()
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, rh.gs(R.string.pumperror))) rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, rh.gs(R.string.pumperror)))
pumpSync.insertAnnouncement(rh.gs(R.string.pumperror), null, danaPump.pumpType(), danaPump.serialNumber) pumpSync.insertAnnouncement(rh.gs(R.string.pumperror), null, danaPump.pumpType(), danaPump.serialNumber)
activityNames.addNotification(Notification.PUMP_ERROR, rh.gs(R.string.pumperror), Notification.URGENT) uiInteraction.addNotification(Notification.PUMP_ERROR, rh.gs(R.string.pumperror), Notification.URGENT)
// response BUSY: error status // response BUSY: error status
} else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'B'.code.toByte() && decryptedBuffer[3] == 'U'.code.toByte() && decryptedBuffer[4] == 'S'.code.toByte() && decryptedBuffer[5] == 'Y'.code.toByte()) { } else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'B'.code.toByte() && decryptedBuffer[3] == 'U'.code.toByte() && decryptedBuffer[4] == 'S'.code.toByte() && decryptedBuffer[5] == 'Y'.code.toByte()) {
aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRSPacket.toHexString(decryptedBuffer)) aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRSPacket.toHexString(decryptedBuffer))
@ -598,7 +598,7 @@ class BLEComm @Inject internal constructor(
mSendQueue.clear() mSendQueue.clear()
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, rh.gs(R.string.connection_error))) rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, rh.gs(R.string.connection_error)))
danaRSPlugin.clearPairing() danaRSPlugin.clearPairing()
activityNames.addNotification(Notification.WRONG_SERIAL_NUMBER, rh.gs(R.string.password_cleared), Notification.URGENT) uiInteraction.addNotification(Notification.WRONG_SERIAL_NUMBER, rh.gs(R.string.password_cleared), Notification.URGENT)
} }
} }
@ -688,7 +688,7 @@ class BLEComm @Inject internal constructor(
aapsLogger.debug(LTag.PUMPBTCOMM, "Pump user password: " + danaPump.rsPassword) aapsLogger.debug(LTag.PUMPBTCOMM, "Pump user password: " + danaPump.rsPassword)
if (!danaPump.isRSPasswordOK) { if (!danaPump.isRSPasswordOK) {
aapsLogger.error(LTag.PUMPBTCOMM, "Wrong pump password") aapsLogger.error(LTag.PUMPBTCOMM, "Wrong pump password")
activityNames.addNotification(Notification.WRONG_PUMP_PASSWORD, rh.gs(R.string.wrongpumppassword), Notification.URGENT) uiInteraction.addNotification(Notification.WRONG_PUMP_PASSWORD, rh.gs(R.string.wrongpumppassword), Notification.URGENT)
disconnect("WrongPassword") disconnect("WrongPassword")
SystemClock.sleep(T.mins(1).msecs()) SystemClock.sleep(T.mins(1).msecs())
} else { } else {

View file

@ -21,7 +21,7 @@ import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.dana.comm.RecordTypes import info.nightscout.pump.dana.comm.RecordTypes
import info.nightscout.pump.dana.events.EventDanaRNewStatus import info.nightscout.pump.dana.events.EventDanaRNewStatus
@ -105,7 +105,7 @@ class DanaRSService : DaggerService() {
@Inject lateinit var danaPump: DanaPump @Inject lateinit var danaPump: DanaPump
@Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var constraintChecker: Constraints @Inject lateinit var constraintChecker: Constraints
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
@Inject lateinit var bleComm: BLEComm @Inject lateinit var bleComm: BLEComm
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var pumpSync: PumpSync @Inject lateinit var pumpSync: PumpSync
@ -199,7 +199,7 @@ class DanaRSService : DaggerService() {
if (abs(timeDiff) > 60 * 60 * 1.5) { if (abs(timeDiff) > 60 * 60 * 1.5) {
aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds - large difference") aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds - large difference")
//If time-diff is very large, warn user until we can synchronize history readings properly //If time-diff is very large, warn user until we can synchronize history readings properly
activityNames.runAlarm(rh.gs(R.string.largetimediff), rh.gs(R.string.largetimedifftitle), R.raw.error) uiInteraction.runAlarm(rh.gs(R.string.largetimediff), rh.gs(R.string.largetimedifftitle), R.raw.error)
//de-initialize pump //de-initialize pump
danaPump.reset() danaPump.reset()
@ -240,7 +240,7 @@ class DanaRSService : DaggerService() {
if (danaPump.dailyTotalUnits > danaPump.maxDailyTotalUnits * Constants.dailyLimitWarning) { if (danaPump.dailyTotalUnits > danaPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
aapsLogger.debug(LTag.PUMPCOMM, "Approaching daily limit: " + danaPump.dailyTotalUnits + "/" + danaPump.maxDailyTotalUnits) aapsLogger.debug(LTag.PUMPCOMM, "Approaching daily limit: " + danaPump.dailyTotalUnits + "/" + danaPump.maxDailyTotalUnits)
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
activityNames.addNotification(Notification.APPROACHING_DAILY_LIMIT, rh.gs(R.string.approachingdailylimit), Notification.URGENT) uiInteraction.addNotification(Notification.APPROACHING_DAILY_LIMIT, rh.gs(R.string.approachingdailylimit), Notification.URGENT)
pumpSync.insertAnnouncement( pumpSync.insertAnnouncement(
rh.gs(R.string.approachingdailylimit) + ": " + danaPump.dailyTotalUnits + "/" + danaPump.maxDailyTotalUnits + "U", rh.gs(R.string.approachingdailylimit) + ": " + danaPump.dailyTotalUnits + "/" + danaPump.maxDailyTotalUnits + "U",
null, null,
@ -308,7 +308,7 @@ class DanaRSService : DaggerService() {
sendMessage(msgSetHistoryEntryV2) sendMessage(msgSetHistoryEntryV2)
danaPump.lastHistoryFetched = min(danaPump.lastHistoryFetched, carbTime - T.mins(1).msecs()) danaPump.lastHistoryFetched = min(danaPump.lastHistoryFetched, carbTime - T.mins(1).msecs())
if (!msgSetHistoryEntryV2.isReceived || msgSetHistoryEntryV2.failed) if (!msgSetHistoryEntryV2.isReceived || msgSetHistoryEntryV2.failed)
activityNames.runAlarm(rh.gs(R.string.carbs_store_error), rh.gs(R.string.error), R.raw.boluserror) uiInteraction.runAlarm(rh.gs(R.string.carbs_store_error), rh.gs(R.string.error), R.raw.boluserror)
} }
val bolusStart = System.currentTimeMillis() val bolusStart = System.currentTimeMillis()
if (insulin > 0) { if (insulin > 0) {

View file

@ -79,7 +79,7 @@ class DanaRSPluginTest : DanaRSTestBase() {
temporaryBasalStorage, temporaryBasalStorage,
fabricPrivacy, fabricPrivacy,
dateUtil, dateUtil,
activityNames, uiInteraction,
danaHistoryDatabase danaHistoryDatabase
) )
} }

View file

@ -4,7 +4,7 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.interfaces.profile.ProfileInstantiator import info.nightscout.interfaces.profile.ProfileInstantiator
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.danars.comm.DanaRSPacket import info.nightscout.pump.danars.comm.DanaRSPacket
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
@ -17,7 +17,7 @@ open class DanaRSTestBase : TestBaseWithProfile() {
@Mock lateinit var sp: SP @Mock lateinit var sp: SP
@Mock lateinit var profileInstantiator: ProfileInstantiator @Mock lateinit var profileInstantiator: ProfileInstantiator
@Mock lateinit var activityNames: ActivityNames @Mock lateinit var uiInteraction: UiInteraction
val injector = HasAndroidInjector { AndroidInjector { } } val injector = HasAndroidInjector { AndroidInjector { } }

View file

@ -15,7 +15,7 @@ class DanaRsPacketBasalGetBasalRateTest : DanaRSTestBase() {
it.rxBus = rxBus it.rxBus = rxBus
it.rh = rh it.rh = rh
it.danaPump = danaPump it.danaPump = danaPump
it.activityNames = activityNames it.uiInteraction = uiInteraction
} }
} }
} }

View file

@ -15,7 +15,7 @@ class DanaRsPacketBolusGetBolusOptionTest : DanaRSTestBase() {
it.rxBus = rxBus it.rxBus = rxBus
it.rh = rh it.rh = rh
it.danaPump = danaPump it.danaPump = danaPump
it.activityNames = activityNames it.uiInteraction = uiInteraction
} }
} }
} }

View file

@ -73,7 +73,7 @@ class DanaRsPacketBolusSetStepBolusStartTest : DanaRSTestBase() {
temporaryBasalStorage, temporaryBasalStorage,
fabricPrivacy, fabricPrivacy,
dateUtil, dateUtil,
activityNames, uiInteraction,
danaHistoryDatabase danaHistoryDatabase
) )
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))

View file

@ -15,7 +15,7 @@ class DanaRsPacketGeneralGetPumpCheckTest : DanaRSTestBase() {
it.rxBus = rxBus it.rxBus = rxBus
it.rh = rh it.rh = rh
it.danaPump = danaPump it.danaPump = danaPump
it.activityNames = activityNames it.uiInteraction = uiInteraction
} }
} }
} }

View file

@ -20,7 +20,7 @@ class DanaRsPacketNotifyAlarmTest : DanaRSTestBase() {
it.rh = rh it.rh = rh
it.pumpSync = pumpSync it.pumpSync = pumpSync
it.danaPump = danaPump it.danaPump = danaPump
it.activityNames = activityNames it.uiInteraction = uiInteraction
} }
} }
} }

View file

@ -77,7 +77,7 @@ class DanaRsPacketNotifyDeliveryRateDisplayTest : DanaRSTestBase() {
temporaryBasalStorage, temporaryBasalStorage,
fabricPrivacy, fabricPrivacy,
dateUtil, dateUtil,
activityNames, uiInteraction,
danaHistoryDatabase danaHistoryDatabase
) )
danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true, 0) danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true, 0)

View file

@ -14,7 +14,7 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.Pump import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.pump.WarnColors import info.nightscout.interfaces.pump.WarnColors
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.diaconn.activities.DiaconnG8HistoryActivity import info.nightscout.pump.diaconn.activities.DiaconnG8HistoryActivity
import info.nightscout.pump.diaconn.activities.DiaconnG8UserOptionsActivity import info.nightscout.pump.diaconn.activities.DiaconnG8UserOptionsActivity
import info.nightscout.pump.diaconn.databinding.DiaconnG8FragmentBinding import info.nightscout.pump.diaconn.databinding.DiaconnG8FragmentBinding
@ -49,7 +49,7 @@ class DiaconnG8Fragment : DaggerFragment() {
@Inject lateinit var warnColors: WarnColors @Inject lateinit var warnColors: WarnColors
@Inject lateinit var dateUtil: DateUtil @Inject lateinit var dateUtil: DateUtil
@Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
private var disposable: CompositeDisposable = CompositeDisposable() private var disposable: CompositeDisposable = CompositeDisposable()
@ -78,7 +78,7 @@ class DiaconnG8Fragment : DaggerFragment() {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
binding.history.setOnClickListener { startActivity(Intent(context, DiaconnG8HistoryActivity::class.java)) } binding.history.setOnClickListener { startActivity(Intent(context, DiaconnG8HistoryActivity::class.java)) }
binding.stats.setOnClickListener { startActivity(Intent(context, activityNames.tddStatsActivity)) } binding.stats.setOnClickListener { startActivity(Intent(context, uiInteraction.tddStatsActivity)) }
binding.userOptions.setOnClickListener { startActivity(Intent(context, DiaconnG8UserOptionsActivity::class.java)) } binding.userOptions.setOnClickListener { startActivity(Intent(context, DiaconnG8UserOptionsActivity::class.java)) }
binding.btconnection.setOnClickListener { binding.btconnection.setOnClickListener {
aapsLogger.debug(LTag.PUMP, "Clicked connect to pump") aapsLogger.debug(LTag.PUMP, "Clicked connect to pump")

View file

@ -33,7 +33,7 @@ import info.nightscout.interfaces.pump.defs.ManufacturerType
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
import info.nightscout.pump.diaconn.database.DiaconnHistoryDatabase import info.nightscout.pump.diaconn.database.DiaconnHistoryDatabase
@ -77,7 +77,7 @@ class DiaconnG8Plugin @Inject constructor(
private val fabricPrivacy: FabricPrivacy, private val fabricPrivacy: FabricPrivacy,
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
private val aapsSchedulers: AapsSchedulers, private val aapsSchedulers: AapsSchedulers,
private val activityNames: ActivityNames, private val uiInteraction: UiInteraction,
private val diaconnHistoryDatabase: DiaconnHistoryDatabase private val diaconnHistoryDatabase: DiaconnHistoryDatabase
) : PumpPluginBase( ) : PumpPluginBase(
PluginDescription() PluginDescription()
@ -216,20 +216,20 @@ class DiaconnG8Plugin @Inject constructor(
override fun setNewBasalProfile(profile: Profile): PumpEnactResult { override fun setNewBasalProfile(profile: Profile): PumpEnactResult {
val result = PumpEnactResult(injector) val result = PumpEnactResult(injector)
if (!isInitialized()) { if (!isInitialized()) {
activityNames.addNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, rh.gs(R.string.pump_not_initialized_profile_not_set), Notification.URGENT) uiInteraction.addNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, rh.gs(R.string.pump_not_initialized_profile_not_set), Notification.URGENT)
result.comment = rh.gs(R.string.pump_not_initialized_profile_not_set) result.comment = rh.gs(R.string.pump_not_initialized_profile_not_set)
return result return result
} else { } else {
rxBus.send(EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)) rxBus.send(EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED))
} }
return if (diaconnG8Service?.updateBasalsInPump(profile) != true) { return if (diaconnG8Service?.updateBasalsInPump(profile) != true) {
activityNames.addNotification(Notification.FAILED_UPDATE_PROFILE, rh.gs(R.string.failed_update_basal_profile), Notification.URGENT) uiInteraction.addNotification(Notification.FAILED_UPDATE_PROFILE, rh.gs(R.string.failed_update_basal_profile), Notification.URGENT)
result.comment = rh.gs(R.string.failed_update_basal_profile) result.comment = rh.gs(R.string.failed_update_basal_profile)
result result
} else { } else {
rxBus.send(EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)) rxBus.send(EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED))
rxBus.send(EventDismissNotification(Notification.FAILED_UPDATE_PROFILE)) rxBus.send(EventDismissNotification(Notification.FAILED_UPDATE_PROFILE))
activityNames.addNotificationValidFor(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60) uiInteraction.addNotificationValidFor(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60)
result.success = true result.success = true
result.enacted = true result.enacted = true
result.comment = "OK" result.comment = "OK"

View file

@ -11,7 +11,7 @@ import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.diaconn.DiaconnG8Pump import info.nightscout.pump.diaconn.DiaconnG8Pump
import info.nightscout.pump.diaconn.R import info.nightscout.pump.diaconn.R
import info.nightscout.pump.diaconn.databinding.DiaconnG8UserOptionsActivityBinding import info.nightscout.pump.diaconn.databinding.DiaconnG8UserOptionsActivityBinding
@ -31,7 +31,7 @@ class DiaconnG8UserOptionsActivity : DaggerAppCompatActivity() {
@Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var commandQueue: CommandQueue @Inject lateinit var commandQueue: CommandQueue
@Inject lateinit var sp: SP @Inject lateinit var sp: SP
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var rh: ResourceHelper @Inject lateinit var rh: ResourceHelper
@ -155,7 +155,7 @@ class DiaconnG8UserOptionsActivity : DaggerAppCompatActivity() {
commandQueue.setUserOptions(object : Callback() { commandQueue.setUserOptions(object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
activityNames.runAlarm(result.comment, rh.gs(R.string.pumperror), R.raw.boluserror) uiInteraction.runAlarm(result.comment, rh.gs(R.string.pumperror), R.raw.boluserror)
} }
} }
}) })

View file

@ -19,7 +19,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.notify import info.nightscout.core.utils.notify
import info.nightscout.core.utils.waitMillis import info.nightscout.core.utils.waitMillis
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.diaconn.DiaconnG8Pump import info.nightscout.pump.diaconn.DiaconnG8Pump
import info.nightscout.pump.diaconn.R import info.nightscout.pump.diaconn.R
import info.nightscout.pump.diaconn.packet.BatteryWarningReportPacket import info.nightscout.pump.diaconn.packet.BatteryWarningReportPacket
@ -49,7 +49,7 @@ class BLECommonService @Inject internal constructor(
private val diaconnG8ResponseMessageHashTable: DiaconnG8ResponseMessageHashTable, private val diaconnG8ResponseMessageHashTable: DiaconnG8ResponseMessageHashTable,
private val diaconnG8SettingResponseMessageHashTable: DiaconnG8SettingResponseMessageHashTable, private val diaconnG8SettingResponseMessageHashTable: DiaconnG8SettingResponseMessageHashTable,
private val diaconnG8Pump: DiaconnG8Pump, private val diaconnG8Pump: DiaconnG8Pump,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) { ) {
companion object { companion object {
@ -338,20 +338,20 @@ class BLECommonService @Inject internal constructor(
if (message is InjectionBlockReportPacket) { if (message is InjectionBlockReportPacket) {
message.handleMessage(data) message.handleMessage(data)
diaconnG8Pump.bolusBlocked = true diaconnG8Pump.bolusBlocked = true
activityNames.runAlarm(rh.gs(R.string.injectionblocked), rh.gs(R.string.injectionblocked), R.raw.boluserror) uiInteraction.runAlarm(rh.gs(R.string.injectionblocked), rh.gs(R.string.injectionblocked), R.raw.boluserror)
return return
} }
// battery warning report // battery warning report
if (message is BatteryWarningReportPacket) { if (message is BatteryWarningReportPacket) {
message.handleMessage(data) message.handleMessage(data)
activityNames.runAlarm(rh.gs(R.string.needbatteryreplace), rh.gs(R.string.batterywarning), R.raw.boluserror) uiInteraction.runAlarm(rh.gs(R.string.needbatteryreplace), rh.gs(R.string.batterywarning), R.raw.boluserror)
return return
} }
// insulin lack warning report // insulin lack warning report
if (message is InsulinLackReportPacket) { if (message is InsulinLackReportPacket) {
message.handleMessage(data) message.handleMessage(data)
activityNames.runAlarm(rh.gs(R.string.needinsullinreplace), rh.gs(R.string.insulinlackwarning), R.raw.boluserror) uiInteraction.runAlarm(rh.gs(R.string.needinsullinreplace), rh.gs(R.string.insulinlackwarning), R.raw.boluserror)
return return
} }

View file

@ -21,7 +21,7 @@ import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.diaconn.DiaconnG8Plugin import info.nightscout.pump.diaconn.DiaconnG8Plugin
import info.nightscout.pump.diaconn.DiaconnG8Pump import info.nightscout.pump.diaconn.DiaconnG8Pump
import info.nightscout.pump.diaconn.R import info.nightscout.pump.diaconn.R
@ -100,7 +100,7 @@ class DiaconnG8Service : DaggerService() {
@Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var diaconnLogUploader: DiaconnLogUploader @Inject lateinit var diaconnLogUploader: DiaconnLogUploader
@Inject lateinit var diaconnHistoryRecordDao: DiaconnHistoryRecordDao @Inject lateinit var diaconnHistoryRecordDao: DiaconnHistoryRecordDao
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
private val mBinder: IBinder = LocalBinder() private val mBinder: IBinder = LocalBinder()
@ -212,7 +212,7 @@ class DiaconnG8Service : DaggerService() {
if (abs(timeDiff) > 60 * 60 * 1.5) { if (abs(timeDiff) > 60 * 60 * 1.5) {
aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds - large difference") aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds - large difference")
//If time-diff is very large, warn user until we can synchronize history readings properly //If time-diff is very large, warn user until we can synchronize history readings properly
activityNames.runAlarm(rh.gs(R.string.largetimediff), rh.gs(R.string.largetimedifftitle), R.raw.error) uiInteraction.runAlarm(rh.gs(R.string.largetimediff), rh.gs(R.string.largetimedifftitle), R.raw.error)
//de-initialize pump //de-initialize pump
diaconnG8Pump.reset() diaconnG8Pump.reset()
@ -244,7 +244,7 @@ class DiaconnG8Service : DaggerService() {
if (diaconnG8Pump.dailyTotalUnits > diaconnG8Pump.maxDailyTotalUnits * Constants.dailyLimitWarning) { if (diaconnG8Pump.dailyTotalUnits > diaconnG8Pump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
aapsLogger.debug(LTag.PUMPCOMM, "Approaching daily limit: " + diaconnG8Pump.dailyTotalUnits + "/" + diaconnG8Pump.maxDailyTotalUnits) aapsLogger.debug(LTag.PUMPCOMM, "Approaching daily limit: " + diaconnG8Pump.dailyTotalUnits + "/" + diaconnG8Pump.maxDailyTotalUnits)
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
activityNames.addNotification(Notification.APPROACHING_DAILY_LIMIT, rh.gs(R.string.approachingdailylimit), Notification.URGENT) uiInteraction.addNotification(Notification.APPROACHING_DAILY_LIMIT, rh.gs(R.string.approachingdailylimit), Notification.URGENT)
pumpSync.insertAnnouncement( pumpSync.insertAnnouncement(
rh.gs(R.string.approachingdailylimit) + ": " + diaconnG8Pump.dailyTotalUnits + "/" + diaconnG8Pump.maxDailyTotalUnits + "U", rh.gs(R.string.approachingdailylimit) + ": " + diaconnG8Pump.dailyTotalUnits + "/" + diaconnG8Pump.maxDailyTotalUnits + "U",
null, null,

View file

@ -26,7 +26,7 @@ import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.queue.CustomCommand import info.nightscout.interfaces.queue.CustomCommand
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.TimeChangeType import info.nightscout.interfaces.utils.TimeChangeType
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -61,7 +61,7 @@ class EopatchPumpPlugin @Inject constructor(
private val patchManager: IPatchManager, private val patchManager: IPatchManager,
private val alarmManager: IAlarmManager, private val alarmManager: IAlarmManager,
private val preferenceManager: IPreferenceManager, private val preferenceManager: IPreferenceManager,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) : PumpPluginBase( ) : PumpPluginBase(
PluginDescription() PluginDescription()
.mainType(PluginType.PUMP) .mainType(PluginType.PUMP)
@ -204,7 +204,7 @@ class EopatchPumpPlugin @Inject constructor(
disposable.dispose() disposable.dispose()
aapsLogger.info(LTag.PUMP, "Basal Profile was set: ${isSuccess ?: false}") aapsLogger.info(LTag.PUMP, "Basal Profile was set: ${isSuccess ?: false}")
if (isSuccess == true) { if (isSuccess == true) {
activityNames.addNotificationValidFor(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60) uiInteraction.addNotificationValidFor(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60)
return PumpEnactResult(injector).success(true).enacted(true) return PumpEnactResult(injector).success(true).enacted(true)
} else { } else {
return PumpEnactResult(injector) return PumpEnactResult(injector)
@ -213,7 +213,7 @@ class EopatchPumpPlugin @Inject constructor(
} else { } else {
preferenceManager.getNormalBasalManager().setNormalBasal(profile) preferenceManager.getNormalBasalManager().setNormalBasal(profile)
preferenceManager.flushNormalBasalManager() preferenceManager.flushNormalBasalManager()
activityNames.addNotificationValidFor(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60) uiInteraction.addNotificationValidFor(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60)
return PumpEnactResult(injector).success(true).enacted(true) return PumpEnactResult(injector).success(true).enacted(true)
} }
} }

View file

@ -22,7 +22,7 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -58,7 +58,7 @@ class AlarmManager @Inject constructor() : IAlarmManager {
@Inject lateinit var sp: SP @Inject lateinit var sp: SP
@Inject lateinit var context: Context @Inject lateinit var context: Context
@Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
@Inject lateinit var pm: IPreferenceManager @Inject lateinit var pm: IPreferenceManager
@Inject lateinit var mAlarmRegistry: IAlarmRegistry @Inject lateinit var mAlarmRegistry: IAlarmRegistry
@ -156,7 +156,7 @@ class AlarmManager @Inject constructor() : IAlarmManager {
val expireTimeString = SimpleDateFormat(resourceHelper.gs(R.string.date_format_yyyy_m_d_e_a_hh_mm_comma), Locale.US).format(expireTimeValue) val expireTimeString = SimpleDateFormat(resourceHelper.gs(R.string.date_format_yyyy_m_d_e_a_hh_mm_comma), Locale.US).format(expireTimeValue)
alarmMsg = resourceHelper.gs(alarmCode.resId, expireTimeString) alarmMsg = resourceHelper.gs(alarmCode.resId, expireTimeString)
} }
activityNames.addNotificationWithAction( uiInteraction.addNotificationWithAction(
id = Notification.EOELOW_PATCH_ALERTS + (alarmCode.aeCode + 10000), id = Notification.EOELOW_PATCH_ALERTS + (alarmCode.aeCode + 10000),
text = alarmMsg, text = alarmMsg,
level = Notification.URGENT, level = Notification.URGENT,
@ -180,7 +180,7 @@ class AlarmManager @Inject constructor() : IAlarmManager {
} }
updateState(alarmCode, AlarmState.HANDLE) updateState(alarmCode, AlarmState.HANDLE)
} else { } else {
activityNames.addNotification( uiInteraction.addNotification(
id = Notification.EOELOW_PATCH_ALERTS + (alarmCode.aeCode + 10000), id = Notification.EOELOW_PATCH_ALERTS + (alarmCode.aeCode + 10000),
text = alarmMsg, text = alarmMsg,
level = Notification.URGENT level = Notification.URGENT

View file

@ -17,7 +17,7 @@ import info.nightscout.androidaps.plugins.pump.eopatch.ble.IPatchManager
import info.nightscout.androidaps.plugins.pump.eopatch.databinding.DialogAlarmBinding import info.nightscout.androidaps.plugins.pump.eopatch.databinding.DialogAlarmBinding
import info.nightscout.androidaps.plugins.pump.eopatch.ui.AlarmHelperActivity import info.nightscout.androidaps.plugins.pump.eopatch.ui.AlarmHelperActivity
import info.nightscout.core.ui.R import info.nightscout.core.ui.R
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -27,7 +27,7 @@ import javax.inject.Inject
class AlarmDialog : DaggerDialogFragment() { class AlarmDialog : DaggerDialogFragment() {
@Inject lateinit var activityNames: ActivityNames @Inject lateinit var uiInteraction: UiInteraction
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var patchManager: IPatchManager @Inject lateinit var patchManager: IPatchManager
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
@ -158,10 +158,10 @@ class AlarmDialog : DaggerDialogFragment() {
} }
private fun startAlarm(reason: String) { private fun startAlarm(reason: String) {
if (sound != 0) activityNames.startAlarm(sound, reason) if (sound != 0) uiInteraction.startAlarm(sound, reason)
} }
private fun stopAlarm(reason: String) { private fun stopAlarm(reason: String) {
activityNames.stopAlarm(reason) uiInteraction.stopAlarm(reason)
} }
} }

View file

@ -54,7 +54,7 @@ import info.nightscout.interfaces.pump.actions.CustomActionType
import info.nightscout.interfaces.pump.defs.ManufacturerType import info.nightscout.interfaces.pump.defs.ManufacturerType
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.TimeChangeType import info.nightscout.interfaces.utils.TimeChangeType
import info.nightscout.pump.common.data.PumpStatus import info.nightscout.pump.common.data.PumpStatus
import info.nightscout.pump.common.defs.PumpDriverState import info.nightscout.pump.common.defs.PumpDriverState
@ -101,7 +101,7 @@ class MedtronicPumpPlugin @Inject constructor(
private val medtronicHistoryData: MedtronicHistoryData, private val medtronicHistoryData: MedtronicHistoryData,
private val rileyLinkServiceData: RileyLinkServiceData, private val rileyLinkServiceData: RileyLinkServiceData,
private val serviceTaskExecutor: ServiceTaskExecutor, private val serviceTaskExecutor: ServiceTaskExecutor,
private val activityNames: ActivityNames, private val uiInteraction: UiInteraction,
dateUtil: DateUtil, dateUtil: DateUtil,
aapsSchedulers: AapsSchedulers, aapsSchedulers: AapsSchedulers,
pumpSync: PumpSync, pumpSync: PumpSync,
@ -577,7 +577,7 @@ class MedtronicPumpPlugin @Inject constructor(
aapsLogger.info(LTag.PUMP, String.format(Locale.ENGLISH, "MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference is %d s. Set time on pump.", timeDiff)) aapsLogger.info(LTag.PUMP, String.format(Locale.ENGLISH, "MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference is %d s. Set time on pump.", timeDiff))
rileyLinkMedtronicService?.medtronicUIComm?.executeCommand(MedtronicCommandType.SetRealTimeClock) rileyLinkMedtronicService?.medtronicUIComm?.executeCommand(MedtronicCommandType.SetRealTimeClock)
if (clock.timeDifference == 0) { if (clock.timeDifference == 0) {
activityNames.addNotificationValidFor(Notification.INSIGHT_DATE_TIME_UPDATED, rh.gs(R.string.pump_time_updated), Notification.INFO, 60) uiInteraction.addNotificationValidFor(Notification.INSIGHT_DATE_TIME_UPDATED, rh.gs(R.string.pump_time_updated), Notification.INFO, 60)
} }
} else { } else {
if (clock.localDeviceTime.year > 2015) { if (clock.localDeviceTime.year > 2015) {
@ -646,7 +646,7 @@ class MedtronicPumpPlugin @Inject constructor(
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Delivery Canceled after Bolus started."); // LOG.debug("MedtronicPumpPlugin::deliverBolus - Delivery Canceled after Bolus started.");
Thread { Thread {
SystemClock.sleep(2000) SystemClock.sleep(2000)
activityNames.runAlarm(rh.gs(R.string.medtronic_cmd_cancel_bolus_not_supported), rh.gs(R.string.medtronic_warning), R.raw.boluserror) uiInteraction.runAlarm(rh.gs(R.string.medtronic_cmd_cancel_bolus_not_supported), rh.gs(R.string.medtronic_warning), R.raw.boluserror)
}.start() }.start()
} }
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
@ -1202,7 +1202,7 @@ class MedtronicPumpPlugin @Inject constructor(
if (rileyLinkMedtronicService?.verifyConfiguration() == true) { if (rileyLinkMedtronicService?.verifyConfiguration() == true) {
serviceTaskExecutor.startTask(WakeAndTuneTask(injector)) serviceTaskExecutor.startTask(WakeAndTuneTask(injector))
} else { } else {
activityNames.runAlarm(rh.gs(R.string.medtronic_error_operation_not_possible_no_configuration), rh.gs(R.string.medtronic_warning), R.raw.boluserror) uiInteraction.runAlarm(rh.gs(R.string.medtronic_error_operation_not_possible_no_configuration), rh.gs(R.string.medtronic_warning), R.raw.boluserror)
} }
} }

View file

@ -26,7 +26,7 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.common.sync.PumpDbEntry import info.nightscout.pump.common.sync.PumpDbEntry
import info.nightscout.pump.common.sync.PumpDbEntryBolus import info.nightscout.pump.common.sync.PumpDbEntryBolus
import info.nightscout.pump.common.sync.PumpDbEntryCarbs import info.nightscout.pump.common.sync.PumpDbEntryCarbs
@ -67,7 +67,7 @@ class MedtronicHistoryData @Inject constructor(
val medtronicPumpStatus: MedtronicPumpStatus, val medtronicPumpStatus: MedtronicPumpStatus,
private val pumpSync: PumpSync, private val pumpSync: PumpSync,
private val pumpSyncStorage: PumpSyncStorage, private val pumpSyncStorage: PumpSyncStorage,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) { ) {
val allHistory: MutableList<PumpHistoryEntry> = mutableListOf() val allHistory: MutableList<PumpHistoryEntry> = mutableListOf()
@ -654,7 +654,7 @@ class MedtronicHistoryData @Inject constructor(
"pumpSerial=${medtronicPumpStatus.serialNumber}]") "pumpSerial=${medtronicPumpStatus.serialNumber}]")
if (tempBasalProcessDTO.durationAsSeconds <= 0) { if (tempBasalProcessDTO.durationAsSeconds <= 0) {
activityNames.addNotification(Notification.MDT_INVALID_HISTORY_DATA, rh.gs(R.string.invalid_history_data), Notification.URGENT) uiInteraction.addNotification(Notification.MDT_INVALID_HISTORY_DATA, rh.gs(R.string.invalid_history_data), Notification.URGENT)
aapsLogger.debug(LTag.PUMP, "syncTemporaryBasalWithPumpId - Skipped") aapsLogger.debug(LTag.PUMP, "syncTemporaryBasalWithPumpId - Skipped")
} else { } else {
val result = pumpSync.syncTemporaryBasalWithTempId( val result = pumpSync.syncTemporaryBasalWithTempId(
@ -695,7 +695,7 @@ class MedtronicHistoryData @Inject constructor(
"duration=${tempBasalProcessDTO.durationAsSeconds} s, pumpSerial=${medtronicPumpStatus.serialNumber}]") "duration=${tempBasalProcessDTO.durationAsSeconds} s, pumpSerial=${medtronicPumpStatus.serialNumber}]")
if (tempBasalProcessDTO.durationAsSeconds <= 0) { if (tempBasalProcessDTO.durationAsSeconds <= 0) {
activityNames.addNotification(Notification.MDT_INVALID_HISTORY_DATA, rh.gs(R.string.invalid_history_data), Notification.URGENT) uiInteraction.addNotification(Notification.MDT_INVALID_HISTORY_DATA, rh.gs(R.string.invalid_history_data), Notification.URGENT)
aapsLogger.debug(LTag.PUMP, "syncTemporaryBasalWithPumpId - Skipped") aapsLogger.debug(LTag.PUMP, "syncTemporaryBasalWithPumpId - Skipped")
} else { } else {
val result = pumpSync.syncTemporaryBasalWithPumpId( val result = pumpSync.syncTemporaryBasalWithPumpId(
@ -963,7 +963,7 @@ class MedtronicHistoryData @Inject constructor(
"pumpSerial=${medtronicPumpStatus.serialNumber}]") "pumpSerial=${medtronicPumpStatus.serialNumber}]")
if (tempBasalProcess.durationAsSeconds <= 0) { if (tempBasalProcess.durationAsSeconds <= 0) {
activityNames.addNotification(Notification.MDT_INVALID_HISTORY_DATA, rh.gs(R.string.invalid_history_data), Notification.URGENT) uiInteraction.addNotification(Notification.MDT_INVALID_HISTORY_DATA, rh.gs(R.string.invalid_history_data), Notification.URGENT)
aapsLogger.debug(LTag.PUMP, "syncTemporaryBasalWithPumpId - Skipped") aapsLogger.debug(LTag.PUMP, "syncTemporaryBasalWithPumpId - Skipped")
} else { } else {
val result = pumpSync.syncTemporaryBasalWithPumpId( val result = pumpSync.syncTemporaryBasalWithPumpId(

View file

@ -11,7 +11,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandTy
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicNotificationType import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicNotificationType
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.core.utils.ByteUtil import info.nightscout.pump.core.utils.ByteUtil
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventDismissNotification import info.nightscout.rx.events.EventDismissNotification
@ -35,7 +35,7 @@ class MedtronicUtil @Inject constructor(
private val rxBus: RxBus, private val rxBus: RxBus,
private val rileyLinkUtil: RileyLinkUtil, private val rileyLinkUtil: RileyLinkUtil,
private val medtronicPumpStatus: MedtronicPumpStatus, private val medtronicPumpStatus: MedtronicPumpStatus,
private val activityNames: ActivityNames private val uiInteraction: UiInteraction
) { ) {
private val ENVELOPE_SIZE = 4 // 0xA7 S1 S2 S3 CMD PARAM_COUNT [PARAMS] private val ENVELOPE_SIZE = 4 // 0xA7 S1 S2 S3 CMD PARAM_COUNT [PARAMS]
@ -94,7 +94,7 @@ class MedtronicUtil @Inject constructor(
} }
fun sendNotification(notificationType: MedtronicNotificationType, rh: ResourceHelper) { fun sendNotification(notificationType: MedtronicNotificationType, rh: ResourceHelper) {
activityNames.addNotification( uiInteraction.addNotification(
notificationType.notificationType, notificationType.notificationType,
rh.gs(notificationType.resourceId), rh.gs(notificationType.resourceId),
notificationType.notificationUrgency notificationType.notificationUrgency
@ -102,7 +102,7 @@ class MedtronicUtil @Inject constructor(
} }
fun sendNotification(notificationType: MedtronicNotificationType, rh: ResourceHelper, vararg parameters: Any?) { fun sendNotification(notificationType: MedtronicNotificationType, rh: ResourceHelper, vararg parameters: Any?) {
activityNames.addNotification( uiInteraction.addNotification(
notificationType.notificationType, notificationType.notificationType,
rh.gs(notificationType.resourceId, *parameters), rh.gs(notificationType.resourceId, *parameters),
notificationType.notificationUrgency notificationType.notificationUrgency

View file

@ -12,7 +12,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceTyp
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil
import info.nightscout.database.impl.serialisation.SealedClassHelper import info.nightscout.database.impl.serialisation.SealedClassHelper
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.core.utils.ByteUtil import info.nightscout.pump.core.utils.ByteUtil
import info.nightscout.rx.TestAapsSchedulers import info.nightscout.rx.TestAapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -27,7 +27,7 @@ import org.mockito.Mock
*/ */
class MedtronicHistoryDataUTest : TestBase() { class MedtronicHistoryDataUTest : TestBase() {
@Mock lateinit var activityNames: ActivityNames @Mock lateinit var uiInteraction: UiInteraction
//TestLogger LOGGER = TestLoggerFactory.getTestLogger(MedtronicHistoryDataUTest.class); //TestLogger LOGGER = TestLoggerFactory.getTestLogger(MedtronicHistoryDataUTest.class);
// var historyPageData = ByteUtil // var historyPageData = ByteUtil
// .createByteArrayFromString( // .createByteArrayFromString(
@ -43,11 +43,11 @@ class MedtronicHistoryDataUTest : TestBase() {
rxBus = RxBus(TestAapsSchedulers(), aapsLogger) rxBus = RxBus(TestAapsSchedulers(), aapsLogger)
medtronicPumpStatus = MedtronicPumpStatus(rh, sp, rxBus, rileyLinkUtil) medtronicPumpStatus = MedtronicPumpStatus(rh, sp, rxBus, rileyLinkUtil)
medtronicUtil = MedtronicUtil(aapsLogger, rxBus, rileyLinkUtil, medtronicPumpStatus, activityNames) medtronicUtil = MedtronicUtil(aapsLogger, rxBus, rileyLinkUtil, medtronicPumpStatus, uiInteraction)
decoder = MedtronicPumpHistoryDecoder(aapsLogger, medtronicUtil, byteUtil) decoder = MedtronicPumpHistoryDecoder(aapsLogger, medtronicUtil, byteUtil)
medtronicHistoryData = MedtronicHistoryData( medtronicHistoryData = MedtronicHistoryData(
packetInjector, aapsLogger, sp, rh, rxBus, activePlugin, packetInjector, aapsLogger, sp, rh, rxBus, activePlugin,
medtronicUtil, decoder, medtronicPumpStatus, pumpSync, pumpSyncStorage, activityNames medtronicUtil, decoder, medtronicPumpStatus, pumpSync, pumpSyncStorage, uiInteraction
) )

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