move Loop to plugins

This commit is contained in:
Milos Kozak 2022-11-18 19:51:39 +01:00
parent 232b44b153
commit 562870723e
27 changed files with 96 additions and 86 deletions
app/src
main
test/java/info/nightscout/androidaps/plugins/aps/loop
interfaces/src/main/java/info/nightscout/interfaces
plugins/main/src/main
ui/src/main/java/info/nightscout/ui/widget

View file

@ -121,7 +121,7 @@
</receiver> </receiver>
<!-- Receive ignore 5m, 15m, 30m requests for carb notifications --> <!-- Receive ignore 5m, 15m, 30m requests for carb notifications -->
<receiver android:name=".plugins.aps.loop.CarbSuggestionReceiver" /> <receiver android:name="info.nightscout.plugins.aps.loop.CarbSuggestionReceiver" />
<!-- Auto start --> <!-- Auto start -->
<receiver <receiver

View file

@ -23,7 +23,7 @@ import info.nightscout.androidaps.danar.DanaRPlugin
import info.nightscout.androidaps.danars.DanaRSPlugin import info.nightscout.androidaps.danars.DanaRSPlugin
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.configBuilder.PluginStore import info.nightscout.androidaps.plugins.configBuilder.PluginStore
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
import info.nightscout.androidaps.plugins.general.wear.WearPlugin import info.nightscout.androidaps.plugins.general.wear.WearPlugin

View file

@ -11,7 +11,7 @@ import info.nightscout.androidaps.implementations.ActivityNamesImpl
import info.nightscout.androidaps.interfaces.stats.DexcomTirCalculator import info.nightscout.androidaps.interfaces.stats.DexcomTirCalculator
import info.nightscout.androidaps.interfaces.stats.TddCalculator import info.nightscout.androidaps.interfaces.stats.TddCalculator
import info.nightscout.androidaps.interfaces.stats.TirCalculator import info.nightscout.androidaps.interfaces.stats.TirCalculator
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.PluginStore import info.nightscout.androidaps.plugins.configBuilder.PluginStore
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImpl import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImpl

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.di
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.activities.MyPreferenceFragment import info.nightscout.androidaps.activities.MyPreferenceFragment
import info.nightscout.androidaps.plugins.aps.loop.LoopFragment import info.nightscout.plugins.aps.loop.LoopFragment
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment
import info.nightscout.androidaps.plugins.general.maintenance.MaintenanceFragment import info.nightscout.androidaps.plugins.general.maintenance.MaintenanceFragment
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment import info.nightscout.androidaps.plugins.general.overview.OverviewFragment

View file

@ -10,7 +10,7 @@ import info.nightscout.androidaps.danar.DanaRPlugin
import info.nightscout.androidaps.danars.DanaRSPlugin import info.nightscout.androidaps.danars.DanaRSPlugin
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.general.dataBroadcaster.DataBroadcastPlugin import info.nightscout.androidaps.plugins.general.dataBroadcaster.DataBroadcastPlugin
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.di
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.plugins.aps.loop.CarbSuggestionReceiver import info.nightscout.plugins.aps.loop.CarbSuggestionReceiver
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkBluetoothStateReceiver import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkBluetoothStateReceiver
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkBroadcastReceiver import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkBroadcastReceiver
import info.nightscout.androidaps.receivers.AutoStartReceiver import info.nightscout.androidaps.receivers.AutoStartReceiver

View file

@ -26,7 +26,7 @@ import javax.inject.Inject
class ActivityNamesImpl @Inject constructor() : ActivityNames { class ActivityNamesImpl @Inject constructor() : ActivityNames {
override val mainActivityClass: Class<*> = MainActivity::class.java override val mainActivity: Class<*> = MainActivity::class.java
override val tddStatsActivity: Class<*> = TDDStatsActivity::class.java override val tddStatsActivity: Class<*> = TDDStatsActivity::class.java
override val historyBrowseActivity: Class<*> = HistoryBrowseActivity::class.java override val historyBrowseActivity: Class<*> = HistoryBrowseActivity::class.java
override val errorHelperActivity: Class<*> = ErrorHelperActivity::class.java override val errorHelperActivity: Class<*> = ErrorHelperActivity::class.java

View file

@ -34,7 +34,7 @@ import info.nightscout.androidaps.events.EventNewBG
import info.nightscout.androidaps.extensions.directionToIcon import info.nightscout.androidaps.extensions.directionToIcon
import info.nightscout.androidaps.extensions.valueToUnitsString import info.nightscout.androidaps.extensions.valueToUnitsString
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification import info.nightscout.plugins.aps.loop.events.EventNewOpenLoopNotification
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity
import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewCalcProgress import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewCalcProgress
import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewGraph import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewGraph

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.wear
import android.content.Context import android.content.Context
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui import info.nightscout.plugins.aps.loop.events.EventLoopUpdateGui
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
import info.nightscout.androidaps.plugins.general.wear.wearintegration.DataHandlerMobile import info.nightscout.androidaps.plugins.general.wear.wearintegration.DataHandlerMobile
import info.nightscout.androidaps.plugins.general.wear.wearintegration.DataLayerListenerServiceMobileHelper import info.nightscout.androidaps.plugins.general.wear.wearintegration.DataLayerListenerServiceMobileHelper

View file

@ -17,6 +17,7 @@ class ConfigImpl @Inject constructor() : Config {
override val PUMPDRIVERS = BuildConfig.FLAVOR == "full" || BuildConfig.FLAVOR == "pumpcontrol" override val PUMPDRIVERS = BuildConfig.FLAVOR == "full" || BuildConfig.FLAVOR == "pumpcontrol"
override val FLAVOR = BuildConfig.FLAVOR override val FLAVOR = BuildConfig.FLAVOR
override val VERSION_NAME = BuildConfig.VERSION_NAME override val VERSION_NAME = BuildConfig.VERSION_NAME
override val BUILD_VERSION = BuildConfig.BUILDVERSION
override val DEBUG = BuildConfig.DEBUG override val DEBUG = BuildConfig.DEBUG
override val currentDeviceModelString = override val currentDeviceModelString =

View file

@ -1,17 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string-array name="aps_modeArray">
<item>@string/closedloop</item>
<item>@string/openloop</item>
<item>@string/lowglucosesuspend</item>
</string-array>
<string-array name="aps_modeValues" translatable="false">
<item>closed</item>
<item>open</item>
<item>lgs</item>
</string-array>
<string-array name="unitsArray"> <string-array name="unitsArray">
<item>mg/dL</item> <item>mg/dL</item>
<item>mmol/L</item> <item>mmol/L</item>

View file

@ -40,7 +40,6 @@
<string name="reset_db_confirm">Do you really want to reset the databases?</string> <string name="reset_db_confirm">Do you really want to reset the databases?</string>
<string name="nav_exit">Exit</string> <string name="nav_exit">Exit</string>
<string name="description_config_builder">Used for configuring the active plugins</string> <string name="description_config_builder">Used for configuring the active plugins</string>
<string name="description_loop">Activate or deactivate the implementation triggering the loop.</string>
<string name="description_overview">Displays the current state of your loop and buttons for most common actions</string> <string name="description_overview">Displays the current state of your loop and buttons for most common actions</string>
<string name="description_persistent_notification">Shows an ongoing notification with a short overview of what your loop is doing</string> <string name="description_persistent_notification">Shows an ongoing notification with a short overview of what your loop is doing</string>
<string name="description_sensitivity_aaps">Sensitivity is calculated the same way like Oref0, but you can specify timeframe to the past. Minimal carb absorption is calculated from max carb absorption time from preferences.</string> <string name="description_sensitivity_aaps">Sensitivity is calculated the same way like Oref0, but you can specify timeframe to the past. Minimal carb absorption is calculated from max carb absorption time from preferences.</string>
@ -65,16 +64,10 @@
<string name="configbuilder_constraints_description">Which constraints are applied?</string> <string name="configbuilder_constraints_description">Which constraints are applied?</string>
<string name="configbuilder_loop">Loop</string> <string name="configbuilder_loop">Loop</string>
<string name="configbuilder_loop_description">Use this to activate AAPS\' loop integration.</string> <string name="configbuilder_loop_description">Use this to activate AAPS\' loop integration.</string>
<string name="loop_aps_label">APS</string>
<string name="loop_constraintsprocessed_label">After processed constraints</string>
<string name="loop_tbrsetbypump_label">Temp basal set by pump</string>
<string name="noapsselected">NO APS SELECTED OR PROVIDED RESULT</string>
<string name="constraints_violation">Constraints violation</string> <string name="constraints_violation">Constraints violation</string>
<string name="changeyourinput">Change your input!</string> <string name="changeyourinput">Change your input!</string>
<string name="configbuilder_bgsource">BG Source</string> <string name="configbuilder_bgsource">BG Source</string>
<string name="configbuilder_bgsource_description">Where should AAPS gain it\'s data from?</string> <string name="configbuilder_bgsource_description">Where should AAPS gain it\'s data from?</string>
<string name="openloop_newsuggestion">New suggestion available</string>
<string name="carbssuggestion">Carbs Suggestion</string>
<string name="profile_label">Profile</string> <string name="profile_label">Profile</string>
<string name="configbuilder_nightscoutversion_label">Nightscout version:</string> <string name="configbuilder_nightscoutversion_label">Nightscout version:</string>
<string name="exported">Preferences exported</string> <string name="exported">Preferences exported</string>
@ -115,7 +108,6 @@
<string name="correctionbous">Corr</string> <string name="correctionbous">Corr</string>
<string name="ns_upload_only">(DANGEROUS TO DISABLE) NS upload only</string> <string name="ns_upload_only">(DANGEROUS TO DISABLE) NS upload only</string>
<string name="ns_upload_only_summary">NS upload only (disabled sync). Not effective on SGV unless a local source like xDrip+ is selected. Not effective on Profiles while NS-Profiles is used.\n!!! WARNING !!! Disabling this option may cause malfunctions and insulin overdose if any of your component (AAPS, NS, xDrip+) is wrong configured. Carefully watch if data displayed by AAPS match the pump state!</string> <string name="ns_upload_only_summary">NS upload only (disabled sync). Not effective on SGV unless a local source like xDrip+ is selected. Not effective on Profiles while NS-Profiles is used.\n!!! WARNING !!! Disabling this option may cause malfunctions and insulin overdose if any of your component (AAPS, NS, xDrip+) is wrong configured. Carefully watch if data displayed by AAPS match the pump state!</string>
<string name="pumpNotInitialized">Pump not initialized!</string>
<string name="units">Units</string> <string name="units">Units</string>
<string name="prefs_range_title">Range for Visualization</string> <string name="prefs_range_title">Range for Visualization</string>
<string name="prefs_range_summary">High and low mark for the charts in Overview and Smartwatch</string> <string name="prefs_range_summary">High and low mark for the charts in Overview and Smartwatch</string>
@ -127,7 +119,6 @@
<string name="ongoingnotificaction">Ongoing Notification</string> <string name="ongoingnotificaction">Ongoing Notification</string>
<string name="old_data">OLD DATA</string> <string name="old_data">OLD DATA</string>
<string name="configbuilder_shortname">CONF</string> <string name="configbuilder_shortname">CONF</string>
<string name="loop_shortname">LOOP</string>
<string name="overview_shortname">HOME</string> <string name="overview_shortname">HOME</string>
<string name="treatments_shortname">TREAT</string> <string name="treatments_shortname">TREAT</string>
<string name="wear_shortname">WEAR</string> <string name="wear_shortname">WEAR</string>
@ -179,7 +170,6 @@
<string name="sensitivityweightedaverage">Sensitivity WeightedAverage</string> <string name="sensitivityweightedaverage">Sensitivity WeightedAverage</string>
<string name="notloadedplugins">Not all profiles loaded!</string> <string name="notloadedplugins">Not all profiles loaded!</string>
<string name="valuesnotstored">Values not stored!</string> <string name="valuesnotstored">Values not stored!</string>
<string name="key_smb_enable_carbs_suggestions_threshold" translatable="false">smb_enable_carbs_suggestions_threshold</string>
<string name="invalid">INVALID</string> <string name="invalid">INVALID</string>
<string name="default_temptargets">Default Temp-Targets</string> <string name="default_temptargets">Default Temp-Targets</string>
<string name="eatingsoon_duration">eatingsoon duration</string> <string name="eatingsoon_duration">eatingsoon duration</string>
@ -220,9 +210,6 @@
<string name="carb_increment_button_message">Number of carbs to add when button is pressed</string> <string name="carb_increment_button_message">Number of carbs to add when button is pressed</string>
<string name="insulin_increment_button_message">Amount of insulin to add when button is pressed</string> <string name="insulin_increment_button_message">Amount of insulin to add when button is pressed</string>
<string name="error_starting_cgm">Could not launch CGM application. Make sure it is installed.</string> <string name="error_starting_cgm">Could not launch CGM application. Make sure it is installed.</string>
<string name="ignore5m">Ignore 5m</string>
<string name="ignore15m">Ignore 15m</string>
<string name="ignore30m">Ignore 30m</string>
<string name="wear_notifysmb_title">Notify on SMB</string> <string name="wear_notifysmb_title">Notify on SMB</string>
<string name="wear_notifysmb_summary">Show SMB on the watch like a standard bolus.</string> <string name="wear_notifysmb_summary">Show SMB on the watch like a standard bolus.</string>
<string name="wear_predictions_summary">Show the predictions on the watchface.</string> <string name="wear_predictions_summary">Show the predictions on the watchface.</string>
@ -232,7 +219,6 @@
<string name="allow_automated_crash_reporting">Allow automated crash reporting and feature usage data to be sent to the developers via the fabric.io service.</string> <string name="allow_automated_crash_reporting">Allow automated crash reporting and feature usage data to be sent to the developers via the fabric.io service.</string>
<string name="g5appnotdetected">Please update your Dexcom app to supported version</string> <string name="g5appnotdetected">Please update your Dexcom app to supported version</string>
<string name="dexcom_app_not_installed">Dexcom app is not installed.</string> <string name="dexcom_app_not_installed">Dexcom app is not installed.</string>
<string name="loop_smbsetbypump_label">SMB set by pump</string>
<string name="overview_show_activity">Activity</string> <string name="overview_show_activity">Activity</string>
<string name="overview_show_bgi">Blood Glucose Impact</string> <string name="overview_show_bgi">Blood Glucose Impact</string>
<string name="overview_show_sensitivity">Sensitivity</string> <string name="overview_show_sensitivity">Sensitivity</string>
@ -241,8 +227,6 @@
<string name="overview_show_iob">Insulin On Board</string> <string name="overview_show_iob">Insulin On Board</string>
<string name="overview_show_basals">Basals</string> <string name="overview_show_basals">Basals</string>
<string name="engineering_mode_enabled">Engineering mode enabled</string> <string name="engineering_mode_enabled">Engineering mode enabled</string>
<string name="smb_frequency_exceeded">A bolus was delivered within the last 3 minutes, skipping SMB</string>
<string name="basal_set_correctly">Basal set correctly</string>
<string name="iobcobcalculator" translatable="false">IobCobCalculator</string> <string name="iobcobcalculator" translatable="false">IobCobCalculator</string>
<string name="absorption_cutoff_title">Meal max absorption time [h]</string> <string name="absorption_cutoff_title">Meal max absorption time [h]</string>
<string name="absorption_cutoff_summary">Time at which any meal is considered absorbed. Remaining carbs will be cut off.</string> <string name="absorption_cutoff_summary">Time at which any meal is considered absorbed. Remaining carbs will be cut off.</string>
@ -311,8 +295,6 @@
<string name="resettodefaults">Reset to defaults</string> <string name="resettodefaults">Reset to defaults</string>
<string name="setupwizard_preferred_aps_mode">Preferred APS mode</string> <string name="setupwizard_preferred_aps_mode">Preferred APS mode</string>
<string name="sendlogfiles">Send today\'s log files to developers along with this time. Unexpected situation.</string> <string name="sendlogfiles">Send today\'s log files to developers along with this time. Unexpected situation.</string>
<string name="loop_openmode_min_change">Minimal request change [%]</string>
<string name="loop_openmode_min_change_summary" formatted="false">Open Loop will popup new change request only if change is bigger than this value in %. Default value is 20%</string>
<string name="key_short_tabtitles" translatable="false">short_tabtitles</string> <string name="key_short_tabtitles" translatable="false">short_tabtitles</string>
<string name="profile_total">== ∑ %1$s U</string> <string name="profile_total">== ∑ %1$s U</string>
<string name="deliverpartofboluswizard">Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm.</string> <string name="deliverpartofboluswizard">Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm.</string>
@ -327,10 +309,6 @@
<string name="key_wear_detailed_delta" translatable="false">wear_detailed_delta</string> <string name="key_wear_detailed_delta" translatable="false">wear_detailed_delta</string>
<string name="chartmenu">Chart menu</string> <string name="chartmenu">Chart menu</string>
<string name="databroadcaster" translatable="false">Data Broadcaster</string> <string name="databroadcaster" translatable="false">Data Broadcaster</string>
<string name="loop_smbrequest_time_label">SMB request time</string>
<string name="loop_smbexecution_time_label">SMB execution time</string>
<string name="loop_tbrrequest_time_label">Temp basal request time</string>
<string name="loop_tbrexecution_time_label">Temp basal execution time</string>
<string name="overview_show_predictions">Predictions</string> <string name="overview_show_predictions">Predictions</string>
<string name="overview_show_treatments">Treatments</string> <string name="overview_show_treatments">Treatments</string>
<string name="overview_show_deviationslope">Deviation slope</string> <string name="overview_show_deviationslope">Deviation slope</string>

View file

@ -19,6 +19,8 @@ import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.plugins.aps.loop.LoopFragment
import info.nightscout.plugins.aps.loop.LoopPlugin
import info.nightscout.plugins.configBuilder.RunningConfiguration import info.nightscout.plugins.configBuilder.RunningConfiguration
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus

View file

@ -9,6 +9,7 @@ interface Config {
val PUMPDRIVERS: Boolean val PUMPDRIVERS: Boolean
val FLAVOR: String val FLAVOR: String
val VERSION_NAME: String val VERSION_NAME: String
val BUILD_VERSION: String
val DEBUG: Boolean val DEBUG: Boolean
val currentDeviceModelString : String val currentDeviceModelString : String
val appName: Int val appName: Int

View file

@ -11,7 +11,7 @@ import androidx.fragment.app.FragmentManager
*/ */
interface ActivityNames { interface ActivityNames {
val mainActivityClass: Class<*> val mainActivity: Class<*>
val tddStatsActivity: Class<*> val tddStatsActivity: Class<*>
val historyBrowseActivity: Class<*> val historyBrowseActivity: Class<*>
val errorHelperActivity: Class<*> val errorHelperActivity: Class<*>

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.aps.loop package info.nightscout.plugins.aps.loop
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.aps.loop package info.nightscout.plugins.aps.loop
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
@ -12,15 +12,15 @@ import android.view.ViewGroup
import androidx.core.view.MenuProvider import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.LoopFragmentBinding
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopSetLastRunGui
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui
import info.nightscout.core.fabric.FabricPrivacy import info.nightscout.core.fabric.FabricPrivacy
import info.nightscout.core.pump.toHtml import info.nightscout.core.pump.toHtml
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.utils.HtmlHelper import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.plugins.R
import info.nightscout.plugins.aps.loop.events.EventLoopSetLastRunGui
import info.nightscout.plugins.aps.loop.events.EventLoopUpdateGui
import info.nightscout.plugins.databinding.LoopFragmentBinding
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -73,7 +73,7 @@ class LoopFragment : DaggerFragment(), MenuProvider {
} }
override fun onCreateMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateMenu(menu: Menu, inflater: MenuInflater) {
menu.add(Menu.FIRST, ID_MENU_RUN, 0, rh.gs(R.string.openapsma_run)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) menu.add(Menu.FIRST, ID_MENU_RUN, 0, rh.gs(R.string.run_now)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
menu.setGroupDividerEnabled(true) menu.setGroupDividerEnabled(true)
} }

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.aps.loop package info.nightscout.plugins.aps.loop
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.NotificationChannel import android.app.NotificationChannel
@ -12,17 +12,11 @@ import android.os.HandlerThread
import android.os.SystemClock import android.os.SystemClock
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.MainActivity
import info.nightscout.androidaps.R
import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.convertedToPercent import info.nightscout.androidaps.extensions.convertedToPercent
import info.nightscout.androidaps.extensions.plannedRemainingMinutes import info.nightscout.androidaps.extensions.plannedRemainingMinutes
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopSetLastRunGui
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.receivers.ReceiverStatusStore import info.nightscout.androidaps.receivers.ReceiverStatusStore
@ -58,6 +52,10 @@ import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.interfaces.utils.HardLimits import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.plugins.R
import info.nightscout.plugins.aps.loop.events.EventLoopSetLastRunGui
import info.nightscout.plugins.aps.loop.events.EventLoopUpdateGui
import info.nightscout.plugins.aps.loop.events.EventNewOpenLoopNotification
import info.nightscout.plugins.configBuilder.RunningConfiguration import info.nightscout.plugins.configBuilder.RunningConfiguration
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.plugins.sync.nsclient.extensions.buildDeviceStatus import info.nightscout.plugins.sync.nsclient.extensions.buildDeviceStatus
@ -87,7 +85,7 @@ class LoopPlugin @Inject constructor(
private val aapsSchedulers: AapsSchedulers, private val aapsSchedulers: AapsSchedulers,
private val rxBus: RxBus, private val rxBus: RxBus,
private val sp: SP, private val sp: SP,
config: Config, private val config: Config,
private val constraintChecker: Constraints, private val constraintChecker: Constraints,
rh: ResourceHelper, rh: ResourceHelper,
private val profileFunction: ProfileFunction, private val profileFunction: ProfileFunction,
@ -253,7 +251,7 @@ class LoopPlugin @Inject constructor(
// Check if we have any result // Check if we have any result
if (apsResult == null) { if (apsResult == null) {
rxBus.send(EventLoopSetLastRunGui(rh.gs(R.string.noapsselected))) rxBus.send(EventLoopSetLastRunGui(rh.gs(R.string.no_aps_selected)))
return return
} }
@ -299,7 +297,7 @@ class LoopPlugin @Inject constructor(
buildDeviceStatus( buildDeviceStatus(
dateUtil, this, iobCobCalculator, profileFunction, dateUtil, this, iobCobCalculator, profileFunction,
activePlugin.activePump, receiverStatusStore, runningConfiguration, activePlugin.activePump, receiverStatusStore, runningConfiguration,
BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION config.VERSION_NAME + "-" + config.BUILD_VERSION
)?.also { )?.also {
repository.insert(it) repository.insert(it)
} }
@ -345,7 +343,7 @@ class LoopPlugin @Inject constructor(
val actionIgnore30m = NotificationCompat.Action(R.drawable.ic_notif_aaps, rh.gs(R.string.ignore30m, "Ignore 30m"), pendingIntent30m) val actionIgnore30m = NotificationCompat.Action(R.drawable.ic_notif_aaps, rh.gs(R.string.ignore30m, "Ignore 30m"), pendingIntent30m)
val builder = NotificationCompat.Builder(context, CHANNEL_ID) val builder = NotificationCompat.Builder(context, CHANNEL_ID)
builder.setSmallIcon(R.drawable.notif_icon) builder.setSmallIcon(R.drawable.notif_icon)
.setContentTitle(rh.gs(R.string.carbssuggestion)) .setContentTitle(rh.gs(R.string.carbs_suggestion))
.setContentText(resultAfterConstraints.carbsRequiredText) .setContentText(resultAfterConstraints.carbsRequiredText)
.setAutoCancel(true) .setAutoCancel(true)
.setPriority(Notification.IMPORTANCE_HIGH) .setPriority(Notification.IMPORTANCE_HIGH)
@ -430,7 +428,7 @@ class LoopPlugin @Inject constructor(
if (resultAfterConstraints.isChangeRequested && allowNotification) { if (resultAfterConstraints.isChangeRequested && allowNotification) {
val builder = NotificationCompat.Builder(context, CHANNEL_ID) val builder = NotificationCompat.Builder(context, CHANNEL_ID)
builder.setSmallIcon(R.drawable.notif_icon) builder.setSmallIcon(R.drawable.notif_icon)
.setContentTitle(rh.gs(R.string.openloop_newsuggestion)) .setContentTitle(rh.gs(R.string.open_loop_new_suggestion))
.setContentText(resultAfterConstraints.toString()) .setContentText(resultAfterConstraints.toString())
.setAutoCancel(true) .setAutoCancel(true)
.setPriority(Notification.IMPORTANCE_HIGH) .setPriority(Notification.IMPORTANCE_HIGH)
@ -458,14 +456,14 @@ class LoopPlugin @Inject constructor(
private fun presentSuggestion(builder: NotificationCompat.Builder) { private fun presentSuggestion(builder: NotificationCompat.Builder) {
// Creates an explicit intent for an Activity in your app // Creates an explicit intent for an Activity in your app
val resultIntent = Intent(context, MainActivity::class.java) val resultIntent = Intent(context, activityNames.mainActivity)
// The stack builder object will contain an artificial back stack for the // The stack builder object will contain an artificial back stack for the
// started Activity. // started Activity.
// This ensures that navigating backward from the Activity leads out of // This ensures that navigating backward from the Activity leads out of
// your application to the Home screen. // your application to the Home screen.
val stackBuilder = TaskStackBuilder.create(context) val stackBuilder = TaskStackBuilder.create(context)
stackBuilder.addParentStack(MainActivity::class.java) stackBuilder.addParentStack(activityNames.mainActivity)
// Adds the Intent that starts the Activity to the top of the stack // Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent) stackBuilder.addNextIntent(resultIntent)
val resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) val resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
@ -492,7 +490,7 @@ class LoopPlugin @Inject constructor(
rxBus.send( rxBus.send(
EventMobileToWear( EventMobileToWear(
EventData.OpenLoopRequest( EventData.OpenLoopRequest(
rh.gs(R.string.openloop_newsuggestion), rh.gs(R.string.open_loop_new_suggestion),
it.constraintsProcessed.toString(), it.constraintsProcessed.toString(),
EventData.OpenLoopRequestConfirmed(dateUtil.now()) EventData.OpenLoopRequestConfirmed(dateUtil.now())
) )
@ -515,7 +513,7 @@ class LoopPlugin @Inject constructor(
buildDeviceStatus( buildDeviceStatus(
dateUtil, this@LoopPlugin, iobCobCalculator, profileFunction, dateUtil, this@LoopPlugin, iobCobCalculator, profileFunction,
activePlugin.activePump, receiverStatusStore, runningConfiguration, activePlugin.activePump, receiverStatusStore, runningConfiguration,
BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION config.VERSION_NAME + "-" + config.BUILD_VERSION
)?.also { )?.also {
repository.insert(it) repository.insert(it)
} }
@ -540,8 +538,8 @@ class LoopPlugin @Inject constructor(
} }
val pump = activePlugin.activePump val pump = activePlugin.activePump
if (!pump.isInitialized()) { if (!pump.isInitialized()) {
aapsLogger.debug(LTag.APS, "applyAPSRequest: " + rh.gs(R.string.pumpNotInitialized)) aapsLogger.debug(LTag.APS, "applyAPSRequest: " + rh.gs(R.string.pump_not_initialized))
callback?.result(PumpEnactResult(injector).comment(R.string.pumpNotInitialized).enacted(false).success(false))?.run() callback?.result(PumpEnactResult(injector).comment(R.string.pump_not_initialized).enacted(false).success(false))?.run()
return return
} }
if (pump.isSuspended()) { if (pump.isSuspended()) {
@ -640,8 +638,8 @@ class LoopPlugin @Inject constructor(
return return
} }
if (!pump.isInitialized()) { if (!pump.isInitialized()) {
aapsLogger.debug(LTag.APS, "applySMBRequest: " + rh.gs(R.string.pumpNotInitialized)) aapsLogger.debug(LTag.APS, "applySMBRequest: " + rh.gs(R.string.pump_not_initialized))
callback?.result(PumpEnactResult(injector).comment(R.string.pumpNotInitialized).enacted(false).success(false))?.run() callback?.result(PumpEnactResult(injector).comment(R.string.pump_not_initialized).enacted(false).success(false))?.run()
return return
} }
if (pump.isSuspended()) { if (pump.isSuspended()) {

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.aps.loop.events package info.nightscout.plugins.aps.loop.events
import info.nightscout.rx.events.EventUpdateGui import info.nightscout.rx.events.EventUpdateGui

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.aps.loop.events package info.nightscout.plugins.aps.loop.events
import info.nightscout.rx.events.EventUpdateGui import info.nightscout.rx.events.EventUpdateGui

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.aps.loop.events package info.nightscout.plugins.aps.loop.events
import info.nightscout.rx.events.Event import info.nightscout.rx.events.Event

View file

Before

(image error) Size: 3 KiB

After

(image error) Size: 3 KiB

View file

@ -3,7 +3,7 @@
android:id="@+id/swipeRefresh" android:id="@+id/swipeRefresh"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".plugins.aps.loop.LoopFragment"> tools:context=".aps.loop.LoopFragment">
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -27,7 +27,7 @@
android:layout_weight="2" android:layout_weight="2"
android:paddingStart="0dp" android:paddingStart="0dp"
android:paddingEnd="5dp" android:paddingEnd="5dp"
android:text="@string/openapsma_last_run_label" android:text="@string/last_run_label"
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
android:textSize="14sp" /> android:textSize="14sp" />
@ -126,7 +126,7 @@
android:layout_weight="2" android:layout_weight="2"
android:paddingStart="0dp" android:paddingStart="0dp"
android:paddingEnd="5dp" android:paddingEnd="5dp"
android:text="@string/openapsma_request_label" android:text="@string/request_label"
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
android:textSize="14sp" /> android:textSize="14sp" />
@ -175,7 +175,7 @@
android:layout_weight="2" android:layout_weight="2"
android:paddingStart="0dp" android:paddingStart="0dp"
android:paddingEnd="5dp" android:paddingEnd="5dp"
android:text="@string/loop_constraintsprocessed_label" android:text="@string/loop_constraints_processed_label"
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
android:textSize="14sp" /> android:textSize="14sp" />
@ -271,7 +271,7 @@
android:layout_weight="2" android:layout_weight="2"
android:paddingStart="0dp" android:paddingStart="0dp"
android:paddingEnd="5dp" android:paddingEnd="5dp"
android:text="@string/loop_tbrrequest_time_label" android:text="@string/loop_tbr_request_time_label"
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
android:textSize="14sp" /> android:textSize="14sp" />
@ -319,7 +319,7 @@
android:layout_weight="2" android:layout_weight="2"
android:paddingStart="0dp" android:paddingStart="0dp"
android:paddingEnd="5dp" android:paddingEnd="5dp"
android:text="@string/loop_tbrexecution_time_label" android:text="@string/loop_tbr_execution_time_label"
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
android:textSize="14sp" /> android:textSize="14sp" />
@ -367,7 +367,7 @@
android:layout_weight="2" android:layout_weight="2"
android:paddingStart="0dp" android:paddingStart="0dp"
android:paddingEnd="5dp" android:paddingEnd="5dp"
android:text="@string/loop_tbrsetbypump_label" android:text="@string/loop_tbr_set_by_pump_label"
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
android:textSize="14sp" /> android:textSize="14sp" />
@ -415,7 +415,7 @@
android:layout_weight="2" android:layout_weight="2"
android:paddingStart="0dp" android:paddingStart="0dp"
android:paddingEnd="5dp" android:paddingEnd="5dp"
android:text="@string/loop_smbrequest_time_label" android:text="@string/loop_smb_request_time_label"
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
android:textSize="14sp" /> android:textSize="14sp" />
@ -463,7 +463,7 @@
android:layout_weight="2" android:layout_weight="2"
android:paddingStart="0dp" android:paddingStart="0dp"
android:paddingEnd="5dp" android:paddingEnd="5dp"
android:text="@string/loop_smbexecution_time_label" android:text="@string/loop_smb_execution_time_label"
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
android:textSize="14sp" /> android:textSize="14sp" />
@ -511,7 +511,7 @@
android:layout_weight="2" android:layout_weight="2"
android:paddingStart="0dp" android:paddingStart="0dp"
android:paddingEnd="5dp" android:paddingEnd="5dp"
android:text="@string/loop_smbsetbypump_label" android:text="@string/loop_smb_set_by_pump_label"
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
android:textSize="14sp" /> android:textSize="14sp" />

View file

@ -59,4 +59,15 @@
<item>@string/key_pregnant</item> <item>@string/key_pregnant</item>
</string-array> </string-array>
<string-array name="aps_modeArray">
<item>@string/closedloop</item>
<item>@string/openloop</item>
<item>@string/lowglucosesuspend</item>
</string-array>
<string-array name="aps_modeValues" translatable="false">
<item>closed</item>
<item>open</item>
<item>lgs</item>
</string-array>
</resources> </resources>

View file

@ -564,4 +564,34 @@
<string name="largedisplay_description">Large display</string> <string name="largedisplay_description">Large display</string>
<string name="skin">Skin</string> <string name="skin">Skin</string>
<!-- Loop -->
<string name="key_smb_enable_carbs_suggestions_threshold" translatable="false">smb_enable_carbs_suggestions_threshold</string>
<string name="executing">Executing</string>
<string name="run_now">Run now</string>
<string name="smb_frequency_exceeded">A bolus was delivered within the last 3 minutes, skipping SMB</string>
<string name="pump_not_initialized">Pump not initialized!</string>
<string name="loop_shortname">LOOP</string>
<string name="description_loop">Activate or deactivate the implementation triggering the loop.</string>
<string name="no_aps_selected">NO APS SELECTED OR PROVIDED RESULT</string>
<string name="ignore5m">Ignore 5m</string>
<string name="ignore15m">Ignore 15m</string>
<string name="ignore30m">Ignore 30m</string>
<string name="carbs_suggestion">Carbs Suggestion</string>
<string name="open_loop_new_suggestion">New suggestion available</string>
<string name="basal_set_correctly">Basal set correctly</string>
<string name="last_run_label">Last run</string>
<string name="loop_aps_label">APS</string>
<string name="request_label">Request</string>
<string name="loop_constraints_processed_label">After processed constraints</string>
<string name="constraints">Constraints</string>
<string name="loop_tbr_request_time_label">Temp basal request time</string>
<string name="loop_tbr_execution_time_label">Temp basal execution time</string>
<string name="loop_tbr_set_by_pump_label">Temp basal set by pump</string>
<string name="loop_smb_request_time_label">SMB request time</string>
<string name="loop_smb_execution_time_label">SMB execution time</string>
<string name="loop_smb_set_by_pump_label">SMB set by pump</string>
<string name="loop_open_mode_min_change">Minimal request change [%]</string>
<string name="loop_open_mode_min_change_summary" formatted="false">Open Loop will popup new change request only if change is bigger than this value in %. Default value is 20%</string>
</resources> </resources>

View file

@ -17,14 +17,14 @@
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference <info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="20" android:defaultValue="20"
android:dialogMessage="@string/loop_openmode_min_change_summary" android:dialogMessage="@string/loop_open_mode_min_change_summary"
android:digits="0123456789" android:digits="0123456789"
android:inputType="number" android:inputType="number"
android:key="@string/key_loop_openmode_min_change" android:key="@string/key_loop_openmode_min_change"
android:maxLines="1" android:maxLines="1"
android:selectAllOnFocus="true" android:selectAllOnFocus="true"
android:singleLine="true" android:singleLine="true"
android:title="@string/loop_openmode_min_change" android:title="@string/loop_open_mode_min_change"
validate:maxNumber="50" validate:maxNumber="50"
validate:minNumber="0" validate:minNumber="0"
validate:testType="numericRange" /> validate:testType="numericRange" />

View file

@ -107,7 +107,7 @@ class Widget : AppWidgetProvider() {
val alpha = sp.getInt(WidgetConfigureActivity.PREF_PREFIX_KEY + appWidgetId, WidgetConfigureActivity.DEFAULT_OPACITY) val alpha = sp.getInt(WidgetConfigureActivity.PREF_PREFIX_KEY + appWidgetId, WidgetConfigureActivity.DEFAULT_OPACITY)
// Create an Intent to launch MainActivity when clicked // Create an Intent to launch MainActivity when clicked
val intent = Intent(context, activityNames.mainActivityClass).also { it.action = intentAction } val intent = Intent(context, activityNames.mainActivity).also { it.action = intentAction }
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
// Widgets allow click handlers to only launch pending intents // Widgets allow click handlers to only launch pending intents
views.setOnClickPendingIntent(R.id.widget_layout, pendingIntent) views.setOnClickPendingIntent(R.id.widget_layout, pendingIntent)