move activities to ui module

This commit is contained in:
Milos Kozak 2022-11-02 23:44:53 +01:00
parent 724587ad46
commit fbeb03f322
45 changed files with 479 additions and 295 deletions

View file

@ -7,25 +7,25 @@ import android.view.View
import android.view.ViewGroup
import com.google.common.base.Joiner
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.databinding.DialogExtendedbolusBinding
import info.nightscout.androidaps.extensions.formatColor
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.HtmlHelper
import info.nightscout.shared.SafeParse
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.extensions.formatColor
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.SafeParse
import info.nightscout.shared.logging.LTag
import java.text.DecimalFormat
import java.util.*
@ -41,6 +41,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
@Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var uel: UserEntryLogger
@Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var activityNames: ActivityNames
private var queryingProtection = false
private var _binding: DialogExtendedbolusBinding? = null
@ -103,7 +104,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
}
}
})

View file

@ -7,31 +7,31 @@ import android.view.View
import android.view.ViewGroup
import com.google.common.base.Joiner
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.transactions.InsertIfNewByTimestampTherapyEventTransaction
import info.nightscout.androidaps.databinding.DialogFillBinding
import info.nightscout.androidaps.extensions.formatColor
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.HtmlHelper
import info.nightscout.shared.SafeParse
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.extensions.formatColor
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.SafeParse
import info.nightscout.shared.logging.LTag
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
import java.util.*
@ -48,6 +48,7 @@ class FillDialog : DialogFragmentWithDate() {
@Inject lateinit var uel: UserEntryLogger
@Inject lateinit var repository: AppRepository
@Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var activityNames: ActivityNames
private var queryingProtection = false
private val disposable = CompositeDisposable()
@ -194,7 +195,7 @@ class FillDialog : DialogFragmentWithDate() {
commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
}
}
})

View file

@ -9,7 +9,6 @@ import android.view.View
import android.view.ViewGroup
import com.google.common.base.Joiner
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.TemporaryTarget
@ -21,7 +20,6 @@ import info.nightscout.androidaps.databinding.DialogInsulinBinding
import info.nightscout.androidaps.extensions.formatColor
import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.*
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.queue.Callback
@ -30,9 +28,8 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.extensions.toSignedString
import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.interfaces.BolusTimer
import info.nightscout.shared.SafeParse
import info.nightscout.shared.logging.LTag
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
import java.text.DecimalFormat
@ -56,6 +53,7 @@ class InsulinDialog : DialogFragmentWithDate() {
@Inject lateinit var bolusTimer: BolusTimer
@Inject lateinit var uel: UserEntryLogger
@Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var activityNames: ActivityNames
companion object {
@ -243,7 +241,7 @@ class InsulinDialog : DialogFragmentWithDate() {
commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
} else {
bolusTimer.removeAutomationEventBolusReminder()
}

View file

@ -12,7 +12,6 @@ import android.view.WindowManager
import androidx.fragment.app.FragmentManager
import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.OfflineEvent
import info.nightscout.androidaps.database.entities.UserEntry.Action
@ -25,9 +24,17 @@ import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.extensions.runOnUiThread
import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.*
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.ConfigBuilder
import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpDescription
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
@ -40,7 +47,8 @@ import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
@ -65,6 +73,7 @@ class LoopDialog : DaggerDialogFragment() {
@Inject lateinit var repository: AppRepository
@Inject lateinit var objectivePlugin: ObjectivesPlugin
@Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var activityNames: ActivityNames
private var queryingProtection = false
private var showOkCancel: Boolean = true
@ -345,7 +354,7 @@ class LoopDialog : DaggerDialogFragment() {
commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(ctx, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
}
}
})

View file

@ -7,23 +7,21 @@ import android.view.View
import android.view.ViewGroup
import com.google.common.base.Joiner
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.databinding.DialogTempbasalBinding
import info.nightscout.androidaps.extensions.formatColor
import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.HtmlHelper
import info.nightscout.shared.SafeParse
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.extensions.formatColor
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.SafeParse
import info.nightscout.shared.logging.LTag
import java.text.DecimalFormat
import java.util.*
@ -40,6 +38,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
@Inject lateinit var ctx: Context
@Inject lateinit var uel: UserEntryLogger
@Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var activityNames: ActivityNames
private var queryingProtection = false
private var isPercentPump = true
@ -125,7 +124,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
val callback: Callback = object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(ctx, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
}
}
}

View file

@ -8,31 +8,31 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.google.common.base.Joiner
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.databinding.DialogTreatmentBinding
import info.nightscout.androidaps.extensions.formatColor
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.HtmlHelper
import info.nightscout.shared.SafeParse
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.extensions.formatColor
import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.SafeParse
import info.nightscout.shared.logging.LTag
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
import java.text.DecimalFormat
@ -51,6 +51,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
@Inject lateinit var uel: UserEntryLogger
@Inject lateinit var repository: AppRepository
@Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var activityNames: ActivityNames
private var queryingProtection = false
private val disposable = CompositeDisposable()
@ -179,7 +180,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
}
}
})

View file

@ -1,11 +1,36 @@
package info.nightscout.androidaps.implementations
import android.content.Context
import android.content.Intent
import androidx.annotation.RawRes
import info.nightscout.androidaps.MainActivity
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.services.AlarmSoundService
import info.nightscout.ui.activities.BolusProgressHelperActivity
import info.nightscout.ui.activities.ErrorHelperActivity
import info.nightscout.ui.activities.TDDStatsActivity
import javax.inject.Inject
class ActivityNamesImpl @Inject constructor() : ActivityNames {
override val mainActivityClass: Class<*>
get() = MainActivity::class.java
override val tddStatsActivity: Class<*>
get() = TDDStatsActivity::class.java
override val errorHelperActivity: Class<*>
get() = ErrorHelperActivity::class.java
override val bolusProgressHelperActivity: Class<*>
get() = BolusProgressHelperActivity::class.java
override fun runAlarm(ctx: Context, status: String, title: String, @RawRes soundId: Int) {
val i = Intent(ctx, errorHelperActivity)
i.putExtra(AlarmSoundService.SOUND_ID, soundId)
i.putExtra(AlarmSoundService.STATUS, status)
i.putExtra(AlarmSoundService.TITLE, title)
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i)
}
}

View file

@ -16,7 +16,6 @@ import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.MainActivity
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.PumpEnactResult
@ -36,6 +35,7 @@ import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.convertedToPercent
import info.nightscout.androidaps.extensions.plannedRemainingMinutes
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.Constraint
@ -100,7 +100,8 @@ class LoopPlugin @Inject constructor(
private val dateUtil: DateUtil,
private val uel: UserEntryLogger,
private val repository: AppRepository,
private val runningConfiguration: RunningConfiguration
private val runningConfiguration: RunningConfiguration,
private val activityNames: ActivityNames
) : PluginBase(
PluginDescription()
.mainType(PluginType.LOOP)
@ -678,7 +679,7 @@ class LoopPlugin @Inject constructor(
commandQueue.tempBasalAbsolute(0.0, durationInMinutes, true, profile, PumpSync.TemporaryBasalType.EMULATED_PUMP_SUSPEND, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(context, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
activityNames.runAlarm(context, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
}
}
})
@ -686,7 +687,7 @@ class LoopPlugin @Inject constructor(
commandQueue.tempBasalPercent(0, durationInMinutes, true, profile, PumpSync.TemporaryBasalType.EMULATED_PUMP_SUSPEND, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(context, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
activityNames.runAlarm(context, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
}
}
})
@ -695,7 +696,7 @@ class LoopPlugin @Inject constructor(
commandQueue.cancelExtended(object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(context, result.comment, rh.gs(R.string.extendedbolusdeliveryerror), R.raw.boluserror)
activityNames.runAlarm(context, result.comment, rh.gs(R.string.extendedbolusdeliveryerror), R.raw.boluserror)
}
}
})
@ -713,7 +714,7 @@ class LoopPlugin @Inject constructor(
commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(context, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
activityNames.runAlarm(context, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
}
}
})

View file

@ -11,15 +11,18 @@ import android.widget.LinearLayout
import androidx.core.content.ContextCompat
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.activities.HistoryBrowseActivity
import info.nightscout.androidaps.activities.TDDStatsActivity
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.ValueWrapper
import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.databinding.ActionsFragmentBinding
import info.nightscout.androidaps.dialogs.*
import info.nightscout.androidaps.dialogs.CareDialog
import info.nightscout.androidaps.dialogs.ExtendedBolusDialog
import info.nightscout.androidaps.dialogs.FillDialog
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
import info.nightscout.androidaps.dialogs.TempBasalDialog
import info.nightscout.androidaps.dialogs.TempTargetDialog
import info.nightscout.androidaps.events.EventCustomActionsChanged
import info.nightscout.androidaps.events.EventExtendedBolusChange
import info.nightscout.androidaps.events.EventInitializationChanged
@ -28,8 +31,15 @@ import info.nightscout.androidaps.events.EventTherapyEventChange
import info.nightscout.androidaps.extensions.toStringMedium
import info.nightscout.androidaps.extensions.toStringShort
import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.*
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.BuildHelper
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
@ -39,16 +49,15 @@ import info.nightscout.androidaps.skins.SkinProvider
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.interfaces.BuildHelper
import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.androidaps.utils.ui.SingleClickButton
import info.nightscout.androidaps.utils.ui.UIRunnable
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.ui.activities.TDDStatsActivity
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
import java.util.*
import javax.inject.Inject
class ActionsFragment : DaggerFragment() {
@ -73,6 +82,7 @@ class ActionsFragment : DaggerFragment() {
@Inject lateinit var uel: UserEntryLogger
@Inject lateinit var repository: AppRepository
@Inject lateinit var loop: Loop
@Inject lateinit var activityNames: ActivityNames
private var disposable: CompositeDisposable = CompositeDisposable()
@ -137,7 +147,7 @@ class ActionsFragment : DaggerFragment() {
commandQueue.cancelExtended(object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(ctx, result.comment, rh.gs(R.string.extendedbolusdeliveryerror), R.raw.boluserror)
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.extendedbolusdeliveryerror), R.raw.boluserror)
}
}
})
@ -157,7 +167,7 @@ class ActionsFragment : DaggerFragment() {
commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(ctx, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
}
}
})

View file

@ -5,7 +5,6 @@ import android.text.Spanned
import com.google.common.base.Joiner
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.BolusCalculatorResult
@ -19,23 +18,38 @@ import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.extensions.formatColor
import info.nightscout.androidaps.extensions.highValueToUnitsToString
import info.nightscout.androidaps.extensions.lowValueToUnitsToString
import info.nightscout.androidaps.interfaces.*
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.BolusTimer
import info.nightscout.androidaps.interfaces.CarbTimer
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpDescription
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.*
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.HtmlHelper
import info.nightscout.androidaps.utils.Round
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.interfaces.BolusTimer
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
import java.util.*
import java.util.LinkedList
import javax.inject.Inject
import kotlin.math.abs
import kotlin.math.max
@ -62,6 +76,7 @@ class BolusWizard @Inject constructor(
@Inject lateinit var bolusTimer: BolusTimer
@Inject lateinit var glucoseStatusProvider: GlucoseStatusProvider
@Inject lateinit var repository: AppRepository
@Inject lateinit var activityNames: ActivityNames
private val disposable = CompositeDisposable()
@ -388,7 +403,7 @@ class BolusWizard @Inject constructor(
commandQueue.bolus(this, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
} else
carbTimer.scheduleAutomationEventEatReminder()
}
@ -435,7 +450,7 @@ class BolusWizard @Inject constructor(
commandQueue.tempBasalAbsolute(0.0, 120, true, profile, PumpSync.TemporaryBasalType.NORMAL, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(ctx, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
}
}
})
@ -443,7 +458,7 @@ class BolusWizard @Inject constructor(
commandQueue.tempBasalPercent(0, 120, true, profile, PumpSync.TemporaryBasalType.NORMAL, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(ctx, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
}
}
})
@ -474,7 +489,7 @@ class BolusWizard @Inject constructor(
commandQueue.bolus(this, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
}
}
})

View file

@ -7,7 +7,15 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpDescription
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
@ -16,7 +24,6 @@ import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.androidaps.receivers.ReceiverStatusStore
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import org.junit.Assert
import org.junit.Before
@ -44,6 +51,7 @@ class LoopPluginTest : TestBase() {
@Mock lateinit var dateUtil: DateUtil
@Mock lateinit var runningConfiguration: RunningConfiguration
@Mock lateinit var config: Config
@Mock lateinit var activityNames: ActivityNames
private lateinit var loopPlugin: LoopPlugin
@ -51,7 +59,8 @@ class LoopPluginTest : TestBase() {
@Before fun prepareMock() {
loopPlugin = LoopPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, config,
constraintChecker, rh, profileFunction, context, commandQueue, activePlugin, virtualPumpPlugin, iobCobCalculator, receiverStatusStore, fabricPrivacy, dateUtil, uel, repository, runningConfiguration)
constraintChecker, rh, profileFunction, context, commandQueue, activePlugin, virtualPumpPlugin, iobCobCalculator, receiverStatusStore, fabricPrivacy, dateUtil, uel,
repository, runningConfiguration, activityNames)
`when`(activePlugin.activePump).thenReturn(virtualPumpPlugin)
`when`(context.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(notificationManager)
}

View file

@ -10,18 +10,4 @@
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<application android:supportsRtl="true">
<activity
android:name="info.nightscout.androidaps.activities.TDDStatsActivity"
android:exported="false" />
<activity
android:name="info.nightscout.androidaps.activities.BolusProgressHelperActivity"
android:exported="false"
android:theme="@style/Theme.MaterialComponents.Translucent" />
<activity
android:name="info.nightscout.androidaps.activities.ErrorHelperActivity"
android:exported="false"
android:theme="@style/Theme.MaterialComponents.Translucent" />
</application>
</manifest>

View file

@ -2,9 +2,6 @@ package info.nightscout.androidaps.di
import dagger.Module
import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.activities.BolusProgressHelperActivity
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.activities.TDDStatsActivity
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.dialogs.ErrorDialog
import info.nightscout.androidaps.dialogs.ProfileViewerDialog
@ -16,10 +13,6 @@ import info.nightscout.androidaps.utils.ui.SingleClickButton
abstract class CoreFragmentsModule {
@ContributesAndroidInjector abstract fun contributesPrefImportListActivity(): PrefImportListActivity
@ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity
@ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity
@ContributesAndroidInjector abstract fun contributeErrorHelperActivity(): ErrorHelperActivity
@ContributesAndroidInjector abstract fun contributesBolusProgressDialog(): BolusProgressDialog
@ContributesAndroidInjector abstract fun contributesErrorDialog(): ErrorDialog
@ContributesAndroidInjector abstract fun contributesProfileViewerDialog(): ProfileViewerDialog

View file

@ -8,7 +8,7 @@ import android.view.ViewGroup
import android.view.Window
import android.view.WindowManager
import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.activities.BolusProgressHelperActivity
import info.nightscout.androidaps.activities.DialogAppCompatActivity
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.core.databinding.DialogBolusprogressBinding
import info.nightscout.androidaps.database.entities.UserEntry.Action
@ -50,7 +50,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
private var amount = 0.0
var id: Long = 0L
private var state: String? = null
private var helpActivity: BolusProgressHelperActivity? = null
private var helpActivity: DialogAppCompatActivity? = null
fun setId(id: Long): BolusProgressDialog {
this.id = id
@ -63,7 +63,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
return this
}
fun setHelperActivity(activity: BolusProgressHelperActivity): BolusProgressDialog {
fun setHelperActivity(activity: DialogAppCompatActivity): BolusProgressDialog {
helpActivity = activity
return this
}

View file

@ -11,7 +11,7 @@ import android.view.ViewGroup
import android.view.Window
import android.view.WindowManager
import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.activities.DialogAppCompatActivity
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.core.databinding.DialogErrorBinding
import info.nightscout.androidaps.database.entities.UserEntry.Action
@ -29,7 +29,7 @@ class ErrorDialog : DaggerDialogFragment() {
@Inject lateinit var uel: UserEntryLogger
@Inject lateinit var ctx: Context
var helperActivity: ErrorHelperActivity? = null
var helperActivity: DialogAppCompatActivity? = null
var status: String = ""
var title: String = ""
var sound: Int = 0

View file

@ -1,5 +1,25 @@
package info.nightscout.androidaps.interfaces
import android.content.Context
import androidx.annotation.RawRes
/**
* Interface to use activities located in different modules
* usage: startActivity(Intent(context, activityNames.xxxx))
*/
interface ActivityNames {
val mainActivityClass: Class<*>
val tddStatsActivity: Class<*>
val errorHelperActivity: Class<*>
val bolusProgressHelperActivity: Class<*>
/**
* Show ErrorHelperActivity and start alarm
* @param ctx Context
* @param status message inside dialog
* @param title title of dialog
* @param soundId sound resource. if == 0 alarm is not started
*/
fun runAlarm(ctx: Context, status: String, title: String, @RawRes soundId: Int = 0)
}

View file

@ -9,12 +9,11 @@ import android.os.Handler
import android.os.IBinder
import android.os.Looper
import dagger.android.DaggerService
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.interfaces.NotificationHolder
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Inject
import kotlin.math.ln
@ -32,6 +31,10 @@ class AlarmSoundService : DaggerService() {
companion object {
const val SOUND_ID = "soundId"
const val STATUS = "status"
const val TITLE = "title"
private const val VOLUME_INCREASE_STEPS = 40 // Total number of steps to increase volume with
private const val VOLUME_INCREASE_INITIAL_SILENT_TIME_MILLIS = 3_000L // Number of milliseconds that the notification should initially be silent
private const val VOLUME_INCREASE_BASE_DELAY_MILLIS = 15_000 // Base delay between volume increments
@ -71,7 +74,7 @@ class AlarmSoundService : DaggerService() {
player?.let { if (it.isPlaying) it.stop() }
if (intent?.hasExtra(ErrorHelperActivity.SOUND_ID) == true) resourceId = intent.getIntExtra(ErrorHelperActivity.SOUND_ID, R.raw.error)
if (intent?.hasExtra(AlarmSoundService.SOUND_ID) == true) resourceId = intent.getIntExtra(AlarmSoundService.SOUND_ID, R.raw.error)
player = MediaPlayer()
try {
val afd = rh.openRawResourceFd(resourceId) ?: return START_NOT_STICKY

View file

@ -5,7 +5,6 @@ import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.os.IBinder
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.interfaces.NotificationHolder
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
@ -70,7 +69,7 @@ class AlarmSoundServiceHelper @Inject constructor(
private fun getServiceIntent(context: Context, sound: Int): Intent {
val alarm = Intent(context, AlarmSoundService::class.java)
alarm.putExtra(ErrorHelperActivity.SOUND_ID, sound)
alarm.putExtra(AlarmSoundService.SOUND_ID, sound)
return alarm
}
}

View file

@ -6,8 +6,6 @@ import android.os.SystemClock
import android.text.Spanned
import androidx.appcompat.app.AppCompatActivity
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.activities.BolusProgressHelperActivity
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.ProfileSealed
@ -22,6 +20,7 @@ import info.nightscout.androidaps.events.EventMobileToWear
import info.nightscout.androidaps.events.EventProfileSwitchChanged
import info.nightscout.androidaps.extensions.getCustomizedName
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.AndroidPermission
import info.nightscout.androidaps.interfaces.BuildHelper
import info.nightscout.androidaps.interfaces.CommandQueue
@ -93,7 +92,8 @@ class CommandQueueImplementation @Inject constructor(
private val repository: AppRepository,
private val fabricPrivacy: FabricPrivacy,
private val config: Config,
private val androidPermission: AndroidPermission
private val androidPermission: AndroidPermission,
private val activityNames: ActivityNames
) : CommandQueue {
private val disposable = CompositeDisposable()
@ -117,7 +117,7 @@ class CommandQueueImplementation @Inject constructor(
setProfile(ProfileSealed.PS(it), it.interfaceIDs.nightscoutId != null, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(context, result.comment, rh.gs(R.string.failedupdatebasalprofile), R.raw.boluserror)
activityNames.runAlarm(context, result.comment, rh.gs(R.string.failedupdatebasalprofile), R.raw.boluserror)
} else {
val nonCustomized = ProfileSealed.PS(it).convertToNonCustomizedProfile(dateUtil)
EffectiveProfileSwitch(
@ -229,7 +229,7 @@ class CommandQueueImplementation @Inject constructor(
val tempCommandQueue = CommandQueueImplementation(
injector, aapsLogger, rxBus, aapsSchedulers, rh,
constraintChecker, profileFunction, activePlugin, context, sp,
buildHelper, dateUtil, repository, fabricPrivacy, config, androidPermission
buildHelper, dateUtil, repository, fabricPrivacy, config, androidPermission, activityNames
)
tempCommandQueue.readStatus(reason, callback)
tempCommandQueue.disposable.clear()
@ -631,7 +631,7 @@ class CommandQueueImplementation @Inject constructor(
val i = Intent()
i.putExtra("insulin", detailedBolusInfo.insulin)
i.putExtra("id", detailedBolusInfo.id)
i.setClass(context, BolusProgressHelperActivity::class.java)
i.setClass(context, activityNames.bolusProgressHelperActivity)
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(i)
}

View file

@ -4,7 +4,6 @@ import android.content.Context
import android.os.PowerManager
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.implementation.R
import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.androidaps.data.DetailedBolusInfo
@ -13,6 +12,7 @@ import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.ValueWrapper
import info.nightscout.androidaps.database.entities.Bolus
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.AndroidPermission
import info.nightscout.androidaps.interfaces.BuildHelper
import info.nightscout.androidaps.interfaces.Config
@ -22,12 +22,13 @@ import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.queue.commands.*
import info.nightscout.androidaps.queue.commands.Command
import info.nightscout.androidaps.queue.commands.CustomCommand
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.implementation.R
import info.nightscout.implementation.queue.commands.CommandBolus
import info.nightscout.implementation.queue.commands.CommandCustomCommand
import info.nightscout.implementation.queue.commands.CommandExtendedBolus
@ -42,7 +43,7 @@ import org.junit.Test
import org.mockito.Mock
import org.mockito.Mockito.anyLong
import org.mockito.Mockito.`when`
import java.util.*
import java.util.Calendar
class CommandQueueImplementationTest : TestBaseWithProfile() {
@ -51,7 +52,7 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
@Mock lateinit var sp: SP
@Mock lateinit var powerManager: PowerManager
@Mock lateinit var repository: AppRepository
@Mock lateinit var fileListProvider: PrefFileListProvider
@Mock lateinit var activityNames: ActivityNames
@Mock lateinit var buildHelper: BuildHelper
@Mock lateinit var androidPermission: AndroidPermission
@ -71,10 +72,11 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
repository: AppRepository,
fabricPrivacy: FabricPrivacy,
config: Config,
androidPermission: AndroidPermission
androidPermission: AndroidPermission,
activityNames: ActivityNames
) : CommandQueueImplementation(
injector, aapsLogger, rxBus, aapsSchedulers, rh, constraintChecker, profileFunction,
activePlugin, context, sp, buildHelper, dateUtil, repository, fabricPrivacy, config, androidPermission
activePlugin, context, sp, buildHelper, dateUtil, repository, fabricPrivacy, config, androidPermission, activityNames
) {
override fun notifyAboutNewCommand() {}
@ -119,7 +121,7 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
constraintChecker, profileFunction, activePlugin, context, sp,
buildHelper, dateUtil,
repository,
fabricPrivacy, config, androidPermission
fabricPrivacy, config, androidPermission, activityNames
)
testPumpPlugin = TestPumpPlugin(injector)
@ -158,7 +160,7 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
constraintChecker, profileFunction, activePlugin, context, sp,
buildHelper,
dateUtil, repository,
fabricPrivacy, config, androidPermission
fabricPrivacy, config, androidPermission, activityNames
)
// start with empty queue
Assert.assertEquals(0, commandQueue.size())

View file

@ -8,6 +8,7 @@ import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.AndroidPermission
import info.nightscout.androidaps.interfaces.BuildHelper
import info.nightscout.androidaps.interfaces.Constraint
@ -34,6 +35,7 @@ class QueueThreadTest : TestBaseWithProfile() {
@Mock lateinit var repository: AppRepository
@Mock lateinit var buildHelper: BuildHelper
@Mock lateinit var androidPermission: AndroidPermission
@Mock lateinit var activityNames: ActivityNames
val injector = HasAndroidInjector {
AndroidInjector {
@ -58,7 +60,7 @@ class QueueThreadTest : TestBaseWithProfile() {
commandQueue = CommandQueueImplementation(
injector, aapsLogger, rxBus, aapsSchedulers, rh, constraintChecker,
profileFunction, activePlugin, context, sp,
buildHelper, dateUtil, repository, fabricPrivacy, config, androidPermission
buildHelper, dateUtil, repository, fabricPrivacy, config, androidPermission, activityNames
)
val pumpDescription = PumpDescription()

View file

@ -10,7 +10,6 @@ import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.activities.TDDStatsActivity
import info.nightscout.androidaps.dana.activities.DanaHistoryActivity
import info.nightscout.androidaps.dana.activities.DanaUserOptionsActivity
import info.nightscout.androidaps.dana.databinding.DanarFragmentBinding
@ -37,6 +36,7 @@ import info.nightscout.androidaps.utils.userEntry.UserEntryMapper.Sources
import info.nightscout.androidaps.utils.WarnColors
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.Dana
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers
@ -59,6 +59,7 @@ class DanaFragment : DaggerFragment() {
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var uel: UserEntryLogger
@Inject lateinit var activityNames: ActivityNames
private var disposable: CompositeDisposable = CompositeDisposable()
@ -107,7 +108,7 @@ class DanaFragment : DaggerFragment() {
}.show(childFragmentManager, "ProfileViewDialog")
}
binding.stats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) }
binding.stats.setOnClickListener { startActivity(Intent(context, activityNames.tddStatsActivity)) }
binding.userOptions.setOnClickListener { startActivity(Intent(context, DanaUserOptionsActivity::class.java)) }
binding.btConnectionLayout.setOnClickListener {
aapsLogger.debug(LTag.PUMP, "Clicked connect to pump")

View file

@ -3,15 +3,14 @@ package info.nightscout.androidaps.dana.activities
import android.content.Context
import android.os.Bundle
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.dana.DanaPump
import info.nightscout.androidaps.dana.R
import info.nightscout.androidaps.dana.databinding.DanarUserOptionsActivityBinding
import info.nightscout.androidaps.events.EventInitializationChanged
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.FabricPrivacy
@ -32,6 +31,7 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() {
@Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var commandQueue: CommandQueue
@Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var activityNames: ActivityNames
private val disposable = CompositeDisposable()
@ -152,7 +152,7 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() {
commandQueue.setUserOptions(object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(context, result.comment, rh.gs(R.string.pumperror), R.raw.boluserror)
activityNames.runAlarm(context, result.comment, rh.gs(R.string.pumperror), R.raw.boluserror)
}
}
})

View file

@ -11,7 +11,6 @@ import javax.inject.Inject;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.activities.ErrorHelperActivity;
import info.nightscout.androidaps.dana.DanaPump;
import info.nightscout.androidaps.dana.events.EventDanaRNewStatus;
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin;
@ -50,19 +49,19 @@ import info.nightscout.androidaps.danar.comm.MsgStatusBasic;
import info.nightscout.androidaps.danar.comm.MsgStatusBolusExtended;
import info.nightscout.androidaps.danar.comm.MsgStatusTempBasal;
import info.nightscout.androidaps.danar.services.AbstractDanaRExecutionService;
import info.nightscout.androidaps.interfaces.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.dialogs.BolusProgressDialog;
import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventProfileSwitchChanged;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.ActivePlugin;
import info.nightscout.androidaps.interfaces.ActivityNames;
import info.nightscout.androidaps.interfaces.CommandQueue;
import info.nightscout.androidaps.interfaces.Profile;
import info.nightscout.androidaps.interfaces.ProfileFunction;
import info.nightscout.androidaps.interfaces.Pump;
import info.nightscout.androidaps.interfaces.PumpSync;
import info.nightscout.shared.logging.AAPSLogger;
import info.nightscout.shared.logging.LTag;
import info.nightscout.androidaps.interfaces.ResourceHelper;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
@ -72,7 +71,8 @@ import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.commands.Command;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.T;
import info.nightscout.androidaps.interfaces.ResourceHelper;
import info.nightscout.shared.logging.AAPSLogger;
import info.nightscout.shared.logging.LTag;
import info.nightscout.shared.sharedPreferences.SP;
public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
@ -91,6 +91,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
@Inject PumpSync pumpSync;
@Inject SP sp;
@Inject DateUtil dateUtil;
@Inject ActivityNames activityNames;
public DanaRv2ExecutionService() {
}
@ -194,7 +195,8 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
if (Math.abs(timeDiff) > 60 * 60 * 1.5) {
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
ErrorHelperActivity.Companion.runAlarm(context, rh.gs(R.string.largetimediff), rh.gs(R.string.largetimedifftitle), R.raw.error);
activityNames.runAlarm(context, rh.gs(R.string.largetimediff),
rh.gs(R.string.largetimedifftitle), R.raw.error);
//deinitialize pump
danaPump.reset();
@ -350,7 +352,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
mSerialIOThread.sendMessage(msgSetHistoryEntry_v2);
danaPump.lastHistoryFetched = Math.min(danaPump.lastHistoryFetched, carbtime - T.Companion.mins(1).msecs());
if (!msgSetHistoryEntry_v2.isReceived() || msgSetHistoryEntry_v2.getFailed())
ErrorHelperActivity.Companion.runAlarm(context, rh.gs(R.string.carbs_store_error)
activityNames.runAlarm(context, rh.gs(R.string.carbs_store_error)
, rh.gs(R.string.error), R.raw.boluserror);
}

View file

@ -9,7 +9,6 @@ import android.os.SystemClock
import dagger.android.DaggerService
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.dana.DanaPump
import info.nightscout.androidaps.dana.comm.RecordTypes
import info.nightscout.androidaps.dana.events.EventDanaRNewStatus
@ -23,25 +22,25 @@ import info.nightscout.androidaps.events.EventInitializationChanged
import info.nightscout.androidaps.events.EventProfileSwitchChanged
import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.queue.commands.Command
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
@ -65,10 +64,9 @@ class DanaRSService : DaggerService() {
@Inject lateinit var context: Context
@Inject lateinit var danaRSPlugin: DanaRSPlugin
@Inject lateinit var danaPump: DanaPump
@Inject lateinit var danaRSMessageHashTable: DanaRSMessageHashTable
@Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
@Inject lateinit var activityNames: ActivityNames
@Inject lateinit var bleComm: BLEComm
@Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var pumpSync: PumpSync
@ -162,7 +160,7 @@ class DanaRSService : DaggerService() {
if (abs(timeDiff) > 60 * 60 * 1.5) {
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
ErrorHelperActivity.runAlarm(context, rh.gs(R.string.largetimediff), rh.gs(R.string.largetimedifftitle), R.raw.error)
activityNames.runAlarm(context, rh.gs(R.string.largetimediff), rh.gs(R.string.largetimedifftitle), R.raw.error)
//de-initialize pump
danaPump.reset()
@ -272,7 +270,7 @@ class DanaRSService : DaggerService() {
sendMessage(msgSetHistoryEntryV2)
danaPump.lastHistoryFetched = min(danaPump.lastHistoryFetched, carbTime - T.mins(1).msecs())
if (!msgSetHistoryEntryV2.isReceived || msgSetHistoryEntryV2.failed)
ErrorHelperActivity.runAlarm(context, rh.gs(R.string.carbs_store_error), rh.gs(R.string.error), R.raw.boluserror)
activityNames.runAlarm(context, rh.gs(R.string.carbs_store_error), rh.gs(R.string.error), R.raw.boluserror)
}
val bolusStart = System.currentTimeMillis()
if (insulin > 0) {

View file

@ -9,7 +9,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.activities.TDDStatsActivity
import info.nightscout.androidaps.diaconn.activities.DiaconnG8HistoryActivity
import info.nightscout.androidaps.diaconn.activities.DiaconnG8UserOptionsActivity
import info.nightscout.androidaps.diaconn.databinding.DiaconnG8FragmentBinding
@ -19,15 +18,16 @@ import info.nightscout.androidaps.events.EventInitializationChanged
import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.events.EventTempBasalChange
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.queue.events.EventQueueChanged
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.WarnColors
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
@ -49,6 +49,7 @@ class DiaconnG8Fragment : DaggerFragment() {
@Inject lateinit var warnColors: WarnColors
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var activityNames: ActivityNames
private var disposable: CompositeDisposable = CompositeDisposable()
@ -77,7 +78,7 @@ class DiaconnG8Fragment : DaggerFragment() {
super.onViewCreated(view, savedInstanceState)
binding.history.setOnClickListener { startActivity(Intent(context, DiaconnG8HistoryActivity::class.java)) }
binding.stats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) }
binding.stats.setOnClickListener { startActivity(Intent(context, activityNames.tddStatsActivity)) }
binding.userOptions.setOnClickListener { startActivity(Intent(context, DiaconnG8UserOptionsActivity::class.java)) }
binding.btconnection.setOnClickListener {
aapsLogger.debug(LTag.PUMP, "Clicked connect to pump")

View file

@ -1,19 +1,17 @@
package info.nightscout.androidaps.diaconn.activities
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.diaconn.DiaconnG8Pump
import info.nightscout.androidaps.diaconn.R
import info.nightscout.androidaps.diaconn.databinding.DiaconnG8UserOptionsActivityBinding
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.ToastUtils
@ -31,6 +29,7 @@ class DiaconnG8UserOptionsActivity : NoSplashAppCompatActivity() {
@Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var commandQueue: CommandQueue
@Inject lateinit var sp: SP
@Inject lateinit var activityNames: ActivityNames
private val disposable = CompositeDisposable()
@ -152,7 +151,7 @@ class DiaconnG8UserOptionsActivity : NoSplashAppCompatActivity() {
commandQueue.setUserOptions(object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(context, result.comment, rh.gs(R.string.pumperror), R.raw.boluserror)
activityNames.runAlarm(context, result.comment, rh.gs(R.string.pumperror), R.raw.boluserror)
}
}
})

View file

@ -2,26 +2,39 @@ package info.nightscout.androidaps.diaconn.service
import android.Manifest
import android.annotation.SuppressLint
import android.bluetooth.*
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothGatt
import android.bluetooth.BluetoothGattCallback
import android.bluetooth.BluetoothGattCharacteristic
import android.bluetooth.BluetoothGattDescriptor
import android.bluetooth.BluetoothGattService
import android.bluetooth.BluetoothManager
import android.bluetooth.BluetoothProfile
import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import android.os.SystemClock
import androidx.core.app.ActivityCompat
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.diaconn.DiaconnG8Pump
import info.nightscout.androidaps.diaconn.R
import info.nightscout.androidaps.diaconn.packet.*
import info.nightscout.androidaps.diaconn.packet.BatteryWarningReportPacket
import info.nightscout.androidaps.diaconn.packet.BigLogInquireResponsePacket
import info.nightscout.androidaps.diaconn.packet.DiaconnG8Packet
import info.nightscout.androidaps.diaconn.packet.DiaconnG8ResponseMessageHashTable
import info.nightscout.androidaps.diaconn.packet.DiaconnG8SettingResponseMessageHashTable
import info.nightscout.androidaps.diaconn.packet.InjectionBlockReportPacket
import info.nightscout.androidaps.diaconn.packet.InsulinLackReportPacket
import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.extensions.notify
import info.nightscout.androidaps.extensions.waitMillis
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import java.util.*
import java.util.UUID
import java.util.concurrent.ScheduledFuture
import javax.inject.Inject
import javax.inject.Singleton
@ -36,6 +49,7 @@ class BLECommonService @Inject internal constructor(
private val diaconnG8ResponseMessageHashTable: DiaconnG8ResponseMessageHashTable,
private val diaconnG8SettingResponseMessageHashTable: DiaconnG8SettingResponseMessageHashTable,
private val diaconnG8Pump: DiaconnG8Pump,
private val activityNames: ActivityNames
) {
companion object {
@ -324,20 +338,20 @@ class BLECommonService @Inject internal constructor(
if (message is InjectionBlockReportPacket) {
message.handleMessage(data)
diaconnG8Pump.bolusBlocked = true
ErrorHelperActivity.runAlarm(context, rh.gs(R.string.injectionblocked), rh.gs(R.string.injectionblocked), R.raw.boluserror)
activityNames.runAlarm(context, rh.gs(R.string.injectionblocked), rh.gs(R.string.injectionblocked), R.raw.boluserror)
return
}
// battery warning report
if (message is BatteryWarningReportPacket) {
message.handleMessage(data)
ErrorHelperActivity.runAlarm(context, rh.gs(R.string.needbatteryreplace), rh.gs(R.string.batterywarning), R.raw.boluserror)
activityNames.runAlarm(context, rh.gs(R.string.needbatteryreplace), rh.gs(R.string.batterywarning), R.raw.boluserror)
return
}
// insulin lack warning report
if (message is InsulinLackReportPacket) {
message.handleMessage(data)
ErrorHelperActivity.runAlarm(context, rh.gs(R.string.needinsullinreplace), rh.gs(R.string.insulinlackwarning), R.raw.boluserror)
activityNames.runAlarm(context, rh.gs(R.string.needinsullinreplace), rh.gs(R.string.insulinlackwarning), R.raw.boluserror)
return
}

View file

@ -9,7 +9,6 @@ import android.os.SystemClock
import dagger.android.DaggerService
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
import info.nightscout.androidaps.diaconn.DiaconnG8Pump
@ -18,7 +17,34 @@ import info.nightscout.androidaps.diaconn.api.DiaconnApiService
import info.nightscout.androidaps.diaconn.api.DiaconnLogUploader
import info.nightscout.androidaps.diaconn.database.DiaconnHistoryRecordDao
import info.nightscout.androidaps.diaconn.events.EventDiaconnG8NewStatus
import info.nightscout.androidaps.diaconn.packet.*
import info.nightscout.androidaps.diaconn.packet.AppConfirmSettingPacket
import info.nightscout.androidaps.diaconn.packet.BasalLimitInquirePacket
import info.nightscout.androidaps.diaconn.packet.BasalSettingPacket
import info.nightscout.androidaps.diaconn.packet.BigAPSMainInfoInquirePacket
import info.nightscout.androidaps.diaconn.packet.BigLogInquirePacket
import info.nightscout.androidaps.diaconn.packet.BigMainInfoInquirePacket
import info.nightscout.androidaps.diaconn.packet.BolusSpeedInquirePacket
import info.nightscout.androidaps.diaconn.packet.BolusSpeedSettingPacket
import info.nightscout.androidaps.diaconn.packet.DiaconnG8Packet
import info.nightscout.androidaps.diaconn.packet.DisplayTimeInquirePacket
import info.nightscout.androidaps.diaconn.packet.DisplayTimeoutSettingPacket
import info.nightscout.androidaps.diaconn.packet.IncarnationInquirePacket
import info.nightscout.androidaps.diaconn.packet.InjectionBasalSettingPacket
import info.nightscout.androidaps.diaconn.packet.InjectionCancelSettingPacket
import info.nightscout.androidaps.diaconn.packet.InjectionExtendedBolusSettingPacket
import info.nightscout.androidaps.diaconn.packet.InjectionSnackInquirePacket
import info.nightscout.androidaps.diaconn.packet.InjectionSnackSettingPacket
import info.nightscout.androidaps.diaconn.packet.LanguageInquirePacket
import info.nightscout.androidaps.diaconn.packet.LanguageSettingPacket
import info.nightscout.androidaps.diaconn.packet.LogStatusInquirePacket
import info.nightscout.androidaps.diaconn.packet.SerialNumInquirePacket
import info.nightscout.androidaps.diaconn.packet.SneckLimitInquirePacket
import info.nightscout.androidaps.diaconn.packet.SoundInquirePacket
import info.nightscout.androidaps.diaconn.packet.SoundSettingPacket
import info.nightscout.androidaps.diaconn.packet.TempBasalInquirePacket
import info.nightscout.androidaps.diaconn.packet.TempBasalSettingPacket
import info.nightscout.androidaps.diaconn.packet.TimeInquirePacket
import info.nightscout.androidaps.diaconn.packet.TimeSettingPacket
import info.nightscout.androidaps.diaconn.pumplog.PumplogUtil
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.events.EventAppExit
@ -26,10 +52,12 @@ import info.nightscout.androidaps.events.EventInitializationChanged
import info.nightscout.androidaps.events.EventProfileSwitchChanged
import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
@ -41,7 +69,6 @@ import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.queue.commands.Command
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
@ -68,7 +95,6 @@ class DiaconnG8Service : DaggerService() {
@Inject lateinit var context: Context
@Inject lateinit var diaconnG8Plugin: DiaconnG8Plugin
@Inject lateinit var diaconnG8Pump: DiaconnG8Pump
@Inject lateinit var diaconnG8ResponseMessageHashTable: DiaconnG8ResponseMessageHashTable
@Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
@ -79,6 +105,7 @@ class DiaconnG8Service : DaggerService() {
@Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var diaconnLogUploader: DiaconnLogUploader
@Inject lateinit var diaconnHistoryRecordDao: DiaconnHistoryRecordDao
@Inject lateinit var activityNames: ActivityNames
private val disposable = CompositeDisposable()
private val mBinder: IBinder = LocalBinder()
@ -190,7 +217,7 @@ class DiaconnG8Service : DaggerService() {
if (abs(timeDiff) > 60 * 60 * 1.5) {
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
ErrorHelperActivity.runAlarm(context, rh.gs(R.string.largetimediff), rh.gs(R.string.largetimedifftitle), R.raw.error)
activityNames.runAlarm(context, rh.gs(R.string.largetimediff), rh.gs(R.string.largetimedifftitle), R.raw.error)
//de-initialize pump
diaconnG8Pump.reset()

View file

@ -7,7 +7,6 @@ import android.os.IBinder
import android.os.SystemClock
import androidx.preference.Preference
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.activities.ErrorHelperActivity.Companion.runAlarm
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.events.EventRefreshOverview
@ -88,6 +87,7 @@ class MedtronicPumpPlugin @Inject constructor(
private val medtronicHistoryData: MedtronicHistoryData,
private val rileyLinkServiceData: RileyLinkServiceData,
private val serviceTaskExecutor: ServiceTaskExecutor,
private val activityNames: ActivityNames,
dateUtil: DateUtil,
aapsSchedulers: AapsSchedulers,
pumpSync: PumpSync,
@ -626,7 +626,7 @@ class MedtronicPumpPlugin @Inject constructor(
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Delivery Canceled after Bolus started.");
Thread {
SystemClock.sleep(2000)
runAlarm(context, rh.gs(R.string.medtronic_cmd_cancel_bolus_not_supported), rh.gs(R.string.medtronic_warning), R.raw.boluserror)
activityNames.runAlarm(context, rh.gs(R.string.medtronic_cmd_cancel_bolus_not_supported), rh.gs(R.string.medtronic_warning), R.raw.boluserror)
}.start()
}
val now = System.currentTimeMillis()
@ -1182,7 +1182,7 @@ class MedtronicPumpPlugin @Inject constructor(
if (rileyLinkMedtronicService?.verifyConfiguration() == true) {
serviceTaskExecutor.startTask(WakeAndTuneTask(injector))
} else {
runAlarm(context, rh.gs(R.string.medtronic_error_operation_not_possible_no_configuration), rh.gs(R.string.medtronic_warning), R.raw.boluserror)
activityNames.runAlarm(context, rh.gs(R.string.medtronic_error_operation_not_possible_no_configuration), rh.gs(R.string.medtronic_warning), R.raw.boluserror)
}
}

View file

@ -5,7 +5,6 @@ import android.os.Handler
import android.os.HandlerThread
import android.text.format.DateFormat
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.activities.ErrorHelperActivity.Companion.runAlarm
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.events.EventPreferenceChange
@ -15,7 +14,17 @@ import info.nightscout.androidaps.events.EventTempBasalChange
import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.plannedRemainingMinutes
import info.nightscout.androidaps.extensions.toStringFull
import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.androidaps.interfaces.PumpDescription
import info.nightscout.androidaps.interfaces.PumpPluginBase
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.common.ManufacturerType
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
@ -27,9 +36,22 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.*
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandDeactivatePod
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandDisableSuspendAlerts
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandHandleTimeChange
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandPlayTestBeep
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandResumeDelivery
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandSilenceAlerts
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandUpdateAlertConfiguration
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.OmnipodDashManager
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.*
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ActivationProgress
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertConfiguration
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertTrigger
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepRepetitionType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.CommandConfirmed
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
@ -61,7 +83,7 @@ import io.reactivex.rxjava3.kotlin.plusAssign
import org.json.JSONObject
import java.time.Duration
import java.time.ZonedDateTime
import java.util.*
import java.util.Date
import java.util.concurrent.CountDownLatch
import javax.inject.Inject
import javax.inject.Singleton
@ -81,7 +103,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
private val aapsSchedulers: AapsSchedulers,
private val fabricPrivacy: FabricPrivacy,
private val dateUtil: DateUtil,
private val activityNames: ActivityNames,
injector: HasAndroidInjector,
aapsLogger: AAPSLogger,
rh: ResourceHelper,
@ -1478,7 +1500,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
private fun showErrorDialog(message: String, sound: Int) {
runAlarm(context, message, rh.gs(R.string.error), sound)
activityNames.runAlarm(context, message, rh.gs(R.string.error), sound)
}
private fun showNotification(id: Int, message: String, urgency: Int, sound: Int?) {

View file

@ -4,9 +4,9 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandPlayTestBeep
import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.PodActivationWizardActivity
@ -33,6 +33,7 @@ class DashPodManagementActivity : NoSplashAppCompatActivity() {
@Inject lateinit var context: Context
@Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var podStateManager: OmnipodDashPodStateManager
@Inject lateinit var activityNames: ActivityNames
private var disposables: CompositeDisposable = CompositeDisposable()
@ -147,7 +148,7 @@ class DashPodManagementActivity : NoSplashAppCompatActivity() {
private fun displayErrorDialog(title: String, message: String, @Suppress("SameParameterValue") withSound: Boolean) {
context.let {
ErrorHelperActivity.runAlarm(it, message, title, if (withSound) R.raw.boluserror else 0)
activityNames.runAlarm(it, message, title, if (withSound) R.raw.boluserror else 0)
}
}
}

View file

@ -10,12 +10,11 @@ import android.view.View
import android.view.ViewGroup
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.BuildHelper
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
@ -49,7 +48,8 @@ import io.reactivex.rxjava3.kotlin.plusAssign
import org.apache.commons.lang3.StringUtils
import java.time.Duration
import java.time.ZonedDateTime
import java.util.*
import java.util.Date
import java.util.TimeZone
import java.util.concurrent.TimeUnit
import javax.inject.Inject
@ -66,7 +66,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
@Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var pumpSync: PumpSync
@Inject lateinit var activityNames: ActivityNames
@Inject lateinit var buildHelper: BuildHelper
companion object {
@ -677,7 +677,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
private fun displayErrorDialog(title: String, message: String, withSound: Boolean) {
context?.let {
ErrorHelperActivity.runAlarm(it, message, title, if (withSound) R.raw.boluserror else 0)
activityNames.runAlarm(it, message, title, if (withSound) R.raw.boluserror else 0)
}
}

View file

@ -1,5 +1,10 @@
package info.nightscout.androidaps.plugins.pump.omnipod.eros;
import static info.nightscout.androidaps.extensions.PumpStateExtensionKt.convertedToAbsolute;
import static info.nightscout.androidaps.extensions.PumpStateExtensionKt.getPlannedRemainingMinutes;
import static info.nightscout.androidaps.extensions.PumpStateExtensionKt.toStringFull;
import static info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.OmnipodConstants.BASAL_STEP_DURATION;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@ -29,7 +34,6 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.activities.ErrorHelperActivity;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.events.EventAppExit;
@ -37,6 +41,7 @@ import info.nightscout.androidaps.events.EventAppInitialized;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.ActivePlugin;
import info.nightscout.androidaps.interfaces.ActivityNames;
import info.nightscout.androidaps.interfaces.CommandQueue;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
@ -46,9 +51,7 @@ import info.nightscout.androidaps.interfaces.Pump;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpPluginBase;
import info.nightscout.androidaps.interfaces.PumpSync;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.schedule.BasalSchedule;
import info.nightscout.shared.logging.AAPSLogger;
import info.nightscout.shared.logging.LTag;
import info.nightscout.androidaps.interfaces.ResourceHelper;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.common.ManufacturerType;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
@ -81,6 +84,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.Al
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.AlertSet;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.BeepConfigType;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.OmnipodConstants;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.schedule.BasalSchedule;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.manager.ErosPodStateManager;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.util.TimeUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.event.EventOmnipodErosActiveAlertsChanged;
@ -98,22 +102,19 @@ import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.AapsOmnipodUtil
import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.OmnipodAlertUtil;
import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.commands.CustomCommand;
import info.nightscout.androidaps.services.AlarmSoundService;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.DecimalFormatter;
import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.Round;
import info.nightscout.androidaps.utils.T;
import info.nightscout.androidaps.utils.TimeChangeType;
import info.nightscout.androidaps.interfaces.ResourceHelper;
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
import info.nightscout.shared.logging.AAPSLogger;
import info.nightscout.shared.logging.LTag;
import info.nightscout.shared.sharedPreferences.SP;
import io.reactivex.rxjava3.disposables.CompositeDisposable;
import static info.nightscout.androidaps.extensions.PumpStateExtensionKt.convertedToAbsolute;
import static info.nightscout.androidaps.extensions.PumpStateExtensionKt.getPlannedRemainingMinutes;
import static info.nightscout.androidaps.extensions.PumpStateExtensionKt.toStringFull;
import static info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.OmnipodConstants.BASAL_STEP_DURATION;
/**
* Created by andy on 23.04.18.
*
@ -129,7 +130,6 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
private final ErosPodStateManager podStateManager;
private final RileyLinkServiceData rileyLinkServiceData;
private final AapsOmnipodErosManager aapsOmnipodErosManager;
private final ErosHistory erosHistory;
private final AapsOmnipodUtil aapsOmnipodUtil;
private final RileyLinkUtil rileyLinkUtil;
private final OmnipodAlertUtil omnipodAlertUtil;
@ -147,6 +147,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
private final ServiceConnection serviceConnection;
private final PumpType pumpType = PumpType.OMNIPOD_EROS;
private final PumpSync pumpSync;
private final ActivityNames activityNames;
private final CompositeDisposable disposable = new CompositeDisposable();
@ -176,7 +177,6 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
ActivePlugin activePlugin,
SP sp,
ErosPodStateManager podStateManager,
ErosHistory erosHistory,
AapsOmnipodErosManager aapsOmnipodErosManager,
CommandQueue commandQueue,
FabricPrivacy fabricPrivacy,
@ -186,7 +186,8 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
RileyLinkUtil rileyLinkUtil,
OmnipodAlertUtil omnipodAlertUtil,
ProfileFunction profileFunction,
PumpSync pumpSync
PumpSync pumpSync,
ActivityNames activityNames
) {
super(new PluginDescription() //
.mainType(PluginType.PUMP) //
@ -209,12 +210,12 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
this.podStateManager = podStateManager;
this.rileyLinkServiceData = rileyLinkServiceData;
this.aapsOmnipodErosManager = aapsOmnipodErosManager;
this.erosHistory = erosHistory;
this.aapsOmnipodUtil = aapsOmnipodUtil;
this.rileyLinkUtil = rileyLinkUtil;
this.omnipodAlertUtil = omnipodAlertUtil;
this.profileFunction = profileFunction;
this.pumpSync = pumpSync;
this.activityNames = activityNames;
pumpDescription = new PumpDescription(pumpType);
@ -896,10 +897,10 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(aapsOmnipodErosManager.translateException(ex));
}
Intent i = new Intent(context, ErrorHelperActivity.class);
i.putExtra(ErrorHelperActivity.SOUND_ID, 0);
i.putExtra(ErrorHelperActivity.STATUS, rh.gs(R.string.omnipod_eros_pod_management_pulse_log_value) + ":\n" + result.toString());
i.putExtra(ErrorHelperActivity.TITLE, rh.gs(R.string.omnipod_eros_pod_management_pulse_log));
Intent i = new Intent(context, activityNames.getErrorHelperActivity());
i.putExtra(AlarmSoundService.SOUND_ID, 0);
i.putExtra(AlarmSoundService.STATUS, rh.gs(R.string.omnipod_eros_pod_management_pulse_log_value) + ":\n" + result.toString());
i.putExtra(AlarmSoundService.TITLE, rh.gs(R.string.omnipod_eros_pod_management_pulse_log));
i.putExtra("clipboardContent", result.toString());
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);

View file

@ -14,16 +14,15 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.activities.ErrorHelperActivity;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.extensions.PumpStateExtensionKt;
import info.nightscout.androidaps.interfaces.ActivityNames;
import info.nightscout.androidaps.interfaces.Profile;
import info.nightscout.androidaps.interfaces.PumpSync;
import info.nightscout.shared.logging.AAPSLogger;
import info.nightscout.shared.logging.LTag;
import info.nightscout.androidaps.interfaces.ResourceHelper;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
@ -79,8 +78,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.eros.rileylink.manager.Om
import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.AapsOmnipodUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.OmnipodAlertUtil;
import info.nightscout.androidaps.utils.T;
import info.nightscout.androidaps.interfaces.ResourceHelper;
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
import info.nightscout.shared.logging.AAPSLogger;
import info.nightscout.shared.logging.LTag;
import info.nightscout.shared.sharedPreferences.SP;
import io.reactivex.rxjava3.subjects.SingleSubject;
@ -99,6 +99,7 @@ public class AapsOmnipodErosManager {
private final OmnipodAlertUtil omnipodAlertUtil;
private final Context context;
private final PumpSync pumpSync;
private final ActivityNames activityNames;
private boolean basalBeepsEnabled;
private boolean bolusBeepsEnabled;
@ -128,7 +129,8 @@ public class AapsOmnipodErosManager {
HasAndroidInjector injector,
OmnipodAlertUtil omnipodAlertUtil,
Context context,
PumpSync pumpSync) {
PumpSync pumpSync,
ActivityNames activityNames) {
this.podStateManager = podStateManager;
this.erosHistory = erosHistory;
@ -141,6 +143,7 @@ public class AapsOmnipodErosManager {
this.omnipodAlertUtil = omnipodAlertUtil;
this.context = context;
this.pumpSync = pumpSync;
this.activityNames = activityNames;
delegate = new OmnipodManager(aapsLogger, aapsSchedulers, communicationService, podStateManager);
@ -965,7 +968,7 @@ public class AapsOmnipodErosManager {
}
private void showErrorDialog(String message, Integer sound) {
ErrorHelperActivity.Companion.runAlarm(context, message, rh.gs(R.string.error), sound);
activityNames.runAlarm(context, message, rh.gs(R.string.error), sound);
}
private void showPodFaultNotification(FaultEventCode faultEventCode) {

View file

@ -6,10 +6,11 @@ import android.os.Bundle
import android.os.Handler
import android.os.HandlerThread
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.BuildHelper
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData
@ -31,8 +32,6 @@ import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.queue.events.EventQueueChanged
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.BuildHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.androidaps.utils.ui.UIRunnable
import io.reactivex.rxjava3.disposables.CompositeDisposable
@ -55,6 +54,7 @@ class ErosPodManagementActivity : NoSplashAppCompatActivity() {
@Inject lateinit var serviceTaskExecutor: ServiceTaskExecutor
@Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var buildHelper: BuildHelper
@Inject lateinit var activityNames: ActivityNames
private var disposables: CompositeDisposable = CompositeDisposable()
private val handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
@ -69,7 +69,8 @@ class ErosPodManagementActivity : NoSplashAppCompatActivity() {
binding.buttonActivatePod.setOnClickListener {
val type: PodActivationWizardActivity.Type = if (podStateManager.isPodInitialized
and podStateManager.activationProgress.isAtLeast(ActivationProgress.PRIMING_COMPLETED)) {
and podStateManager.activationProgress.isAtLeast(ActivationProgress.PRIMING_COMPLETED)
) {
PodActivationWizardActivity.Type.SHORT
} else {
PodActivationWizardActivity.Type.LONG
@ -111,7 +112,11 @@ class ErosPodManagementActivity : NoSplashAppCompatActivity() {
commandQueue.customCommand(CommandPlayTestBeep(), object : Callback() {
override fun run() {
if (!result.success) {
displayErrorDialog(rh.gs(R.string.omnipod_common_warning), rh.gs(R.string.omnipod_common_two_strings_concatenated_by_colon, rh.gs(R.string.omnipod_common_error_failed_to_play_test_beep), result.comment), false)
displayErrorDialog(
rh.gs(R.string.omnipod_common_warning),
rh.gs(R.string.omnipod_common_two_strings_concatenated_by_colon, rh.gs(R.string.omnipod_common_error_failed_to_play_test_beep), result.comment),
false
)
}
}
})
@ -124,7 +129,11 @@ class ErosPodManagementActivity : NoSplashAppCompatActivity() {
commandQueue.customCommand(CommandReadPulseLog(), object : Callback() {
override fun run() {
if (!result.success) {
displayErrorDialog(rh.gs(R.string.omnipod_common_warning), rh.gs(R.string.omnipod_common_two_strings_concatenated_by_colon, rh.gs(R.string.omnipod_eros_error_failed_to_read_pulse_log), result.comment), false)
displayErrorDialog(
rh.gs(R.string.omnipod_common_warning),
rh.gs(R.string.omnipod_common_two_strings_concatenated_by_colon, rh.gs(R.string.omnipod_eros_error_failed_to_read_pulse_log), result.comment),
false
)
}
}
})
@ -224,15 +233,17 @@ class ErosPodManagementActivity : NoSplashAppCompatActivity() {
private fun displayErrorDialog(title: String, message: String, @Suppress("SameParameterValue") withSound: Boolean) {
context.let {
ErrorHelperActivity.runAlarm(it, message, title, if (withSound) R.raw.boluserror else 0)
activityNames.runAlarm(it, message, title, if (withSound) R.raw.boluserror else 0)
}
}
private fun displayNotConfiguredDialog() {
context.let {
UIRunnable {
OKDialog.show(it, rh.gs(R.string.omnipod_common_warning),
rh.gs(R.string.omnipod_eros_error_operation_not_possible_no_configuration), null)
OKDialog.show(
it, rh.gs(R.string.omnipod_common_warning),
rh.gs(R.string.omnipod_eros_error_operation_not_possible_no_configuration), null
)
}.run()
}
}

View file

@ -10,9 +10,9 @@ import android.view.View
import android.view.ViewGroup
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus
@ -56,7 +56,7 @@ import io.reactivex.rxjava3.kotlin.plusAssign
import org.apache.commons.lang3.StringUtils
import org.joda.time.DateTime
import org.joda.time.Duration
import java.util.*
import java.util.TimeZone
import javax.inject.Inject
class OmnipodErosOverviewFragment : DaggerFragment() {
@ -81,6 +81,7 @@ class OmnipodErosOverviewFragment : DaggerFragment() {
@Inject lateinit var omnipodManager: AapsOmnipodErosManager
@Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var activityNames: ActivityNames
private var disposables: CompositeDisposable = CompositeDisposable()
@ -285,12 +286,14 @@ class OmnipodErosOverviewFragment : DaggerFragment() {
podInfoBinding.timeOnPod.text = readableZonedTime(podStateManager.time)
podInfoBinding.timeOnPod.setTextColor(
rh.gac(context,
rh.gac(
context,
if (podStateManager.timeDeviatesMoreThan(OmnipodConstants.TIME_DEVIATION_THRESHOLD)) {
R.attr.warningColor
} else {
R.attr.defaultTextColor
})
}
)
)
val expiresAt = podStateManager.expiresAt
if (expiresAt == null) {
@ -299,13 +302,15 @@ class OmnipodErosOverviewFragment : DaggerFragment() {
} else {
podInfoBinding.podExpiryDate.text = readableZonedTime(expiresAt)
podInfoBinding.podExpiryDate.setTextColor(
rh.gac(context,
rh.gac(
context,
if (DateTime.now().isAfter(expiresAt)) {
R.attr.warningColor
} else {
R.attr.defaultTextColor
}
))
)
)
}
if (podStateManager.isPodFaulted) {
@ -338,12 +343,14 @@ class OmnipodErosOverviewFragment : DaggerFragment() {
podInfoBinding.reservoir.text = rh.gs(R.string.omnipod_common_overview_reservoir_value, podStateManager.reservoirLevel)
podInfoBinding.reservoir.setTextColor(
rh.gac(context,
rh.gac(
context,
if (podStateManager.reservoirLevel < lowReservoirThreshold) {
R.attr.warningColor
} else {
R.attr.defaultTextColor
})
}
)
)
}
@ -367,12 +374,14 @@ class OmnipodErosOverviewFragment : DaggerFragment() {
if (podStateManager.isPodInitialized && podStateManager.lastSuccessfulCommunication != null) {
podInfoBinding.lastConnection.text = readableDuration(podStateManager.lastSuccessfulCommunication)
val lastConnectionColor =
rh.gac(context,
rh.gac(
context,
if (omnipodErosPumpPlugin.isUnreachableAlertTimeoutExceeded(getPumpUnreachableTimeout().millis)) {
R.attr.warningColor
} else {
R.attr.defaultTextColor
})
}
)
podInfoBinding.lastConnection.setTextColor(lastConnectionColor)
} else {
podInfoBinding.lastConnection.setTextColor(rh.gac(context, R.attr.defaultTextColor))
@ -420,12 +429,14 @@ class OmnipodErosOverviewFragment : DaggerFragment() {
}
val podStatusColor =
rh.gac( context,
rh.gac(
context,
if (!podStateManager.isPodActivationCompleted || podStateManager.isPodDead || podStateManager.isSuspended || (podStateManager.isPodRunning && !podStateManager.isBasalCertain)) {
R.attr.warningColor
} else {
R.attr.defaultTextColor
})
}
)
podInfoBinding.podStatus.setTextColor(podStatusColor)
}
@ -581,7 +592,7 @@ class OmnipodErosOverviewFragment : DaggerFragment() {
private fun displayErrorDialog(title: String, message: String, withSound: Boolean) {
context?.let {
ErrorHelperActivity.runAlarm(it, message, title, if (withSound) R.raw.boluserror else 0)
activityNames.runAlarm(it, message, title, if (withSound) R.raw.boluserror else 0)
}
}

View file

@ -5,16 +5,16 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.plugins.pump.common.defs.TempBasalPair
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.ErosHistory
import info.nightscout.androidaps.plugins.pump.omnipod.eros.manager.AapsOmnipodErosManager
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.TestAapsSchedulers
import org.joda.time.DateTimeZone
import org.joda.time.tz.UTCProvider
@ -27,7 +27,6 @@ import org.mockito.Mock
import org.mockito.Mockito
import org.mockito.Mockito.`when`
import org.mockito.invocation.InvocationOnMock
import java.util.*
class OmnipodErosPumpPluginTest : TestBase() {
@ -35,7 +34,7 @@ class OmnipodErosPumpPluginTest : TestBase() {
@Mock lateinit var rh: ResourceHelper
@Mock(answer = Answers.RETURNS_DEEP_STUBS) lateinit var activePlugin: ActivePlugin
@Mock lateinit var aapsOmnipodErosManager: AapsOmnipodErosManager
@Mock lateinit var erosHistory: ErosHistory
@Mock lateinit var activityNames: ActivityNames
@Mock lateinit var commandQueue: CommandQueue
@Mock lateinit var rileyLinkUtil: RileyLinkUtil
@Mock lateinit var pumpSync: PumpSync
@ -53,9 +52,9 @@ class OmnipodErosPumpPluginTest : TestBase() {
// mock all the things
val plugin = OmnipodErosPumpPlugin(
injector, aapsLogger, TestAapsSchedulers(), rxBusWrapper, null,
rh, activePlugin, null, null, erosHistory, aapsOmnipodErosManager, commandQueue,
rh, activePlugin, null, null, aapsOmnipodErosManager, commandQueue,
null, null, null, null,
rileyLinkUtil, null, null, pumpSync
rileyLinkUtil, null, null, pumpSync, activityNames
)
val pumpState = PumpSync.PumpState(null, null, null, null, "")
`when`(pumpSync.expectedPumpState()).thenReturn(pumpState)

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<application android:supportsRtl="true">
<activity
android:name=".widget.WidgetConfigureActivity"
@ -23,6 +23,19 @@
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</receiver>
<activity
android:name=".activities.TDDStatsActivity"
android:exported="false" />
<activity
android:name="info.nightscout.ui.activities.BolusProgressHelperActivity"
android:exported="false"
android:theme="@style/Theme.MaterialComponents.Translucent" />
<activity
android:name=".activities.ErrorHelperActivity"
android:exported="false"
android:theme="@style/Theme.MaterialComponents.Translucent" />
</application>
</manifest>

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.activities
package info.nightscout.ui.activities
import android.os.Bundle
import info.nightscout.androidaps.activities.DialogAppCompatActivity
import info.nightscout.androidaps.dialogs.BolusProgressDialog
class BolusProgressHelperActivity : DialogAppCompatActivity() {

View file

@ -1,13 +1,15 @@
package info.nightscout.androidaps.activities
package info.nightscout.ui.activities
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.annotation.RawRes
import info.nightscout.androidaps.activities.DialogAppCompatActivity
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.transactions.InsertTherapyEventAnnouncementTransaction
import info.nightscout.androidaps.dialogs.ErrorDialog
import info.nightscout.androidaps.services.AlarmSoundService
import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
@ -25,28 +27,12 @@ class ErrorHelperActivity : DialogAppCompatActivity() {
super.onCreate(savedInstanceState)
val errorDialog = ErrorDialog()
errorDialog.helperActivity = this
errorDialog.status = intent.getStringExtra(STATUS) ?: ""
errorDialog.sound = intent.getIntExtra(SOUND_ID, R.raw.error)
errorDialog.title = intent.getStringExtra(TITLE)?: ""
errorDialog.status = intent.getStringExtra(AlarmSoundService.STATUS) ?: ""
errorDialog.sound = intent.getIntExtra(AlarmSoundService.SOUND_ID, R.raw.error)
errorDialog.title = intent.getStringExtra(AlarmSoundService.TITLE) ?: ""
errorDialog.show(supportFragmentManager, "Error")
if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true))
disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(intent.getStringExtra(STATUS) ?: "")).subscribe()
}
companion object {
const val SOUND_ID = "soundId"
const val STATUS = "status"
const val TITLE = "title"
fun runAlarm(ctx: Context, status: String, title: String, @RawRes soundId: Int = 0) {
val i = Intent(ctx, ErrorHelperActivity::class.java)
i.putExtra(SOUND_ID, soundId)
i.putExtra(STATUS, status)
i.putExtra(TITLE, title)
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i)
}
disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(intent.getStringExtra(AlarmSoundService.STATUS) ?: "")).subscribe()
}
}

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.activities
package info.nightscout.ui.activities
import android.annotation.SuppressLint
import android.graphics.Color
import android.graphics.Rect
import android.os.Bundle
import android.text.TextUtils
@ -15,8 +14,8 @@ import android.widget.EditText
import android.widget.TableLayout
import android.widget.TableRow
import android.widget.TextView
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.core.databinding.ActivityTddStatsBinding
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.TotalDailyDose
import info.nightscout.androidaps.events.EventDanaRSyncStatus
@ -25,7 +24,6 @@ import info.nightscout.androidaps.extensions.total
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.FabricPrivacy
@ -33,11 +31,13 @@ import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.SafeParse
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.ui.databinding.ActivityTddStatsBinding
import io.reactivex.rxjava3.disposables.CompositeDisposable
import java.text.DateFormat
import java.text.DecimalFormat
import java.text.SimpleDateFormat
import java.util.*
import java.util.Date
import java.util.Locale
import javax.inject.Inject
import kotlin.math.min
import kotlin.math.roundToInt
@ -55,7 +55,7 @@ class TDDStatsActivity : NoSplashAppCompatActivity() {
private lateinit var binding: ActivityTddStatsBinding
private val disposable = CompositeDisposable()
lateinit var tbb: String
private lateinit var tbb: String
private var magicNumber = 0.0
private var decimalFormat: DecimalFormat = DecimalFormat("0.000")
private var historyList: MutableList<TotalDailyDose> = mutableListOf()

View file

@ -2,6 +2,9 @@ package info.nightscout.ui.di
import dagger.Module
import dagger.android.ContributesAndroidInjector
import info.nightscout.ui.activities.BolusProgressHelperActivity
import info.nightscout.ui.activities.ErrorHelperActivity
import info.nightscout.ui.activities.TDDStatsActivity
import info.nightscout.ui.dialogs.CalibrationDialog
import info.nightscout.ui.dialogs.CarbsDialog
@ -11,4 +14,9 @@ abstract class UiModule {
@ContributesAndroidInjector abstract fun contributesCalibrationDialog(): CalibrationDialog
@ContributesAndroidInjector abstract fun contributesCarbsDialog(): CarbsDialog
@ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity
@ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity
@ContributesAndroidInjector abstract fun contributeErrorHelperActivity(): ErrorHelperActivity
}

View file

@ -8,7 +8,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.google.common.base.Joiner
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.TemporaryTarget
@ -18,23 +17,35 @@ import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
import info.nightscout.androidaps.extensions.formatColor
import info.nightscout.androidaps.interfaces.*
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.BolusTimer
import info.nightscout.androidaps.interfaces.CarbTimer
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.androidaps.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.*
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.HtmlHelper
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.logging.LTag
import info.nightscout.ui.R
import info.nightscout.ui.databinding.DialogCarbsBinding
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
import java.text.DecimalFormat
import java.util.*
import java.util.LinkedList
import java.util.concurrent.TimeUnit
import javax.inject.Inject
import kotlin.math.max
@ -54,6 +65,7 @@ class CarbsDialog : DialogFragmentWithDate() {
@Inject lateinit var commandQueue: CommandQueue
@Inject lateinit var repository: AppRepository
@Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var activityNames: ActivityNames
companion object {
@ -367,7 +379,7 @@ class CarbsDialog : DialogFragmentWithDate() {
override fun run() {
carbTimer.removeAutomationEventEatReminder()
if (!result.success) {
ErrorHelperActivity.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
} else if (sp.getBoolean(R.string.key_usebolusreminder, false) && remindBolus)
bolusTimer.scheduleAutomationEventBolusReminder()
}

View file

@ -6,7 +6,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="info.nightscout.androidaps.activities.TDDStatsActivity">
tools:context="info.nightscout.ui.activities.TDDStatsActivity">
<ScrollView
android:layout_width="match_parent"