This commit is contained in:
Milos Kozak 2023-09-19 14:36:36 +02:00
parent d939f7ba99
commit 1ff6aa7bbf
14 changed files with 14 additions and 19 deletions

View file

@ -56,7 +56,6 @@ import info.nightscout.interfaces.constraints.ConstraintsChecker
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.maintenance.PrefFileListProvider
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.smsCommunicator.SmsCommunicator
@ -283,7 +282,7 @@ class MainActivity : DaggerAppCompatActivityWithResult() {
private fun start() {
binding.splash.visibility = View.GONE
//Check here if loop plugin is disabled. Else check via constraints
if (!(loop as PluginBase).isEnabled()) versionCheckerUtils.triggerCheckVersion()
if (!loop.isEnabled()) versionCheckerUtils.triggerCheckVersion()
setUserStats()
setupViews()

View file

@ -1,4 +1,4 @@
package info.nightscout.interfaces.iob
/** All COB up to now, including carbs not yet processed by IobCob calculation. */
class CobInfo(val timestamp: Long, val displayCob: Double?, val futureCarbs: Double)
data class CobInfo(val timestamp: Long, val displayCob: Double?, val futureCarbs: Double)

View file

@ -5,4 +5,5 @@ interface SmsCommunicator {
var messages: ArrayList<Sms>
fun sendNotificationToAllNumbers(text: String): Boolean
fun sendSMS(sms: Sms): Boolean
fun isEnabled(): Boolean
}

View file

@ -27,7 +27,6 @@ import info.nightscout.interfaces.iob.GlucoseStatusProvider
import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.DetailedBolusInfo
@ -455,7 +454,7 @@ class BolusWizard @Inject constructor(
if (insulinAfterConstraints > 0 || carbs > 0) {
if (useSuperBolus) {
uel.log(Action.SUPERBOLUS_TBR, Sources.WizardDialog)
if ((loop as PluginBase).isEnabled()) {
if (loop.isEnabled()) {
loop.goToZeroTemp(2 * 60, profile, OfflineEvent.Reason.SUPER_BOLUS)
rxBus.send(EventRefreshOverview("WizardDialog"))
}

View file

@ -13,7 +13,6 @@ import info.nightscout.interfaces.db.PersistenceLayer
import info.nightscout.interfaces.iob.GlucoseStatusProvider
import info.nightscout.interfaces.iob.InMemoryGlucoseValue
import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.rx.logging.AAPSLogger
@ -141,7 +140,7 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec
if (useSuperBolus() == YES && sp.getBoolean(info.nightscout.core.utils.R.string.key_usesuperbolus, false)) {
superBolus = true
}
if ((loop as PluginBase).isEnabled() && loop.isSuperBolus) superBolus = false
if (loop.isEnabled() && loop.isSuperBolus) superBolus = false
// Trend
val glucoseStatus = glucoseStatusProvider.glucoseStatusData
var trend = false

View file

@ -5,7 +5,6 @@ import info.nightscout.database.ValueWrapper
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
@ -42,7 +41,7 @@ class CommandSetProfile constructor(
// Send SMS notification if ProfileSwitch is coming from NS
val profileSwitch = repository.getEffectiveProfileSwitchActiveAt(dateUtil.now()).blockingGet()
if (profileSwitch is ValueWrapper.Existing && r.enacted && hasNsId && !config.NSCLIENT) {
if ((smsCommunicator as PluginBase).isEnabled())
if (smsCommunicator.isEnabled())
smsCommunicator.sendNotificationToAllNumbers(rh.gs(info.nightscout.core.ui.R.string.profile_set_ok))
}
}

View file

@ -30,7 +30,7 @@ class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) {
@DrawableRes override fun icon(): Int = R.drawable.ic_stop_24dp
override fun doAction(callback: Callback) {
if ((loopPlugin as PluginBase).isEnabled()) {
if (loopPlugin.isEnabled()) {
(loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, false)
configBuilder.storeSettings("ActionLoopDisable")
uel.log(UserEntry.Action.LOOP_DISABLED, Sources.Automation, title)

View file

@ -28,7 +28,7 @@ class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) {
@DrawableRes override fun icon(): Int = R.drawable.ic_play_circle_outline_24dp
override fun doAction(callback: Callback) {
if (!(loopPlugin as PluginBase).isEnabled()) {
if (!loopPlugin.isEnabled()) {
(loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, true)
configBuilder.storeSettings("ActionLoopEnable")
rxBus.send(EventRefreshOverview("ActionLoopEnable"))

View file

@ -20,7 +20,6 @@ import info.nightscout.interfaces.AndroidPermission
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.smsCommunicator.SmsCommunicator
import info.nightscout.shared.interfaces.ResourceHelper
import javax.inject.Inject
@ -86,7 +85,7 @@ class AndroidPermissionImpl @Inject constructor(
@Synchronized
override fun notifyForSMSPermissions(activity: FragmentActivity, smsCommunicator: SmsCommunicator) {
if ((smsCommunicator as PluginBase).isEnabled()) {
if (smsCommunicator.isEnabled()) {
if (permissionNotGranted(activity, Manifest.permission.RECEIVE_SMS))
activePlugin.activeOverview.addNotification(
id = Notification.PERMISSION_SMS,

View file

@ -13,7 +13,6 @@ import info.nightscout.configuration.maintenance.PrefsFileContract
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.locale.LocaleHelper
import info.nightscout.interfaces.maintenance.ImportExportPrefs
import info.nightscout.interfaces.permissions.OptimizationPermissionContract
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventThemeSwitch
import info.nightscout.rx.logging.AAPSLogger

View file

@ -1,4 +1,4 @@
package info.nightscout.interfaces.permissions
package info.nightscout.configuration.activities
import android.content.Context
import android.content.Intent

View file

@ -1038,7 +1038,7 @@ class DataHandlerMobile @Inject constructor(
get() {
var ret = ""
// decide if enabled/disabled closed/open; what Plugin as APS?
if ((loop as PluginBase).isEnabled()) {
if (loop.isEnabled()) {
ret += if (constraintChecker.isClosedLoopAllowed().value()) {
rh.gs(R.string.loop_status_closed) + "\n"
} else {
@ -1137,7 +1137,7 @@ class DataHandlerMobile @Inject constructor(
private fun generateStatusString(profile: Profile?): String {
var status = ""
profile ?: return rh.gs(info.nightscout.core.ui.R.string.noprofile)
if (!(loop as PluginBase).isEnabled()) status += rh.gs(R.string.disabled_loop) + "\n"
if (!loop.isEnabled()) status += rh.gs(R.string.disabled_loop) + "\n"
return status
}

View file

@ -189,7 +189,7 @@ class LoopDialog : DaggerDialogFragment() {
binding.overviewReconnect.visibility = View.VISIBLE
}
!(loop as PluginBase).isEnabled() -> {
!loop.isEnabled() -> {
binding.overviewLoop.visibility = View.VISIBLE
binding.overviewEnable.visibility = View.VISIBLE
binding.overviewDisable.visibility = View.GONE