TreatmentsActivity -> ui module

This commit is contained in:
Milos Kozak 2022-11-05 23:20:36 +01:00
parent d49b988e95
commit b4edb71e27
68 changed files with 506 additions and 361 deletions

View file

@ -86,10 +86,6 @@
android:name=".activities.HistoryBrowseActivity" android:name=".activities.HistoryBrowseActivity"
android:exported="false" android:exported="false"
android:theme="@style/AppTheme" /> android:theme="@style/AppTheme" />
<activity
android:name=".activities.TreatmentsActivity"
android:exported="false"
android:theme="@style/AppTheme" />
<activity <activity
android:name=".activities.ProfileHelperActivity" android:name=".activities.ProfileHelperActivity"
android:exported="false" android:exported="false"

View file

@ -35,7 +35,7 @@ import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.activities.PreferencesActivity import info.nightscout.androidaps.activities.PreferencesActivity
import info.nightscout.androidaps.activities.ProfileHelperActivity import info.nightscout.androidaps.activities.ProfileHelperActivity
import info.nightscout.androidaps.activities.SingleFragmentActivity import info.nightscout.androidaps.activities.SingleFragmentActivity
import info.nightscout.androidaps.activities.TreatmentsActivity import info.nightscout.ui.activities.TreatmentsActivity
import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.databinding.ActivityMainBinding import info.nightscout.androidaps.databinding.ActivityMainBinding

View file

@ -12,7 +12,6 @@ import com.google.android.material.datepicker.MaterialDatePicker
import com.jjoe64.graphview.GraphView import com.jjoe64.graphview.GraphView
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.fragments.HistoryBrowserData
import info.nightscout.androidaps.databinding.ActivityHistorybrowseBinding import info.nightscout.androidaps.databinding.ActivityHistorybrowseBinding
import info.nightscout.androidaps.events.EventAutosensCalculationFinished import info.nightscout.androidaps.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.events.EventCustomCalculationFinished import info.nightscout.androidaps.events.EventCustomCalculationFinished
@ -280,7 +279,6 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
binding.zoom.text = rangeToDisplay.toString() binding.zoom.text = rangeToDisplay.toString()
} }
@Suppress("UNUSED_PARAMETER")
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
fun updateGUI(from: String) { fun updateGUI(from: String) {
aapsLogger.debug(LTag.UI, "updateGui $from") aapsLogger.debug(LTag.UI, "updateGui $from")

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.activities.fragments package info.nightscout.androidaps.activities
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository

View file

@ -19,7 +19,7 @@ import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.plugins.profile.ProfilePlugin import info.nightscout.plugins.profile.ProfilePlugin
import info.nightscout.plugins.profile.events.EventLocalProfileChanged import info.nightscout.androidaps.events.EventLocalProfileChanged
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.T

View file

@ -2,12 +2,31 @@ package info.nightscout.androidaps.db
import android.content.Context import android.content.Context
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.* import info.nightscout.androidaps.database.entities.Bolus
import info.nightscout.androidaps.events.* import info.nightscout.androidaps.database.entities.Carbs
import info.nightscout.androidaps.database.entities.EffectiveProfileSwitch
import info.nightscout.androidaps.database.entities.ExtendedBolus
import info.nightscout.androidaps.database.entities.Food
import info.nightscout.androidaps.database.entities.GlucoseValue
import info.nightscout.androidaps.database.entities.OfflineEvent
import info.nightscout.androidaps.database.entities.ProfileSwitch
import info.nightscout.androidaps.database.entities.TemporaryBasal
import info.nightscout.androidaps.database.entities.TemporaryTarget
import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged
import info.nightscout.androidaps.events.EventExtendedBolusChange
import info.nightscout.androidaps.events.EventFoodDatabaseChanged
import info.nightscout.androidaps.events.EventNewBG
import info.nightscout.androidaps.events.EventNewHistoryData
import info.nightscout.androidaps.events.EventOfflineChange
import info.nightscout.androidaps.events.EventProfileSwitchChanged
import info.nightscout.androidaps.events.EventTempBasalChange
import info.nightscout.androidaps.events.EventTempTargetChange
import info.nightscout.androidaps.events.EventTherapyEventChange
import info.nightscout.androidaps.events.EventTreatmentChange
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData
import info.nightscout.ui.widget.Widget import info.nightscout.ui.widget.Widget
import io.reactivex.rxjava3.disposables.Disposable import io.reactivex.rxjava3.disposables.Disposable
import javax.inject.Inject import javax.inject.Inject

View file

@ -7,7 +7,6 @@ import info.nightscout.androidaps.activities.HistoryBrowseActivity
import info.nightscout.androidaps.activities.PreferencesActivity import info.nightscout.androidaps.activities.PreferencesActivity
import info.nightscout.androidaps.activities.ProfileHelperActivity import info.nightscout.androidaps.activities.ProfileHelperActivity
import info.nightscout.androidaps.activities.SingleFragmentActivity import info.nightscout.androidaps.activities.SingleFragmentActivity
import info.nightscout.androidaps.activities.TreatmentsActivity
import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSettingActivity import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSettingActivity
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity
import info.nightscout.androidaps.plugins.source.activities.RequestDexcomPermissionActivity import info.nightscout.androidaps.plugins.source.activities.RequestDexcomPermissionActivity
@ -17,7 +16,6 @@ import info.nightscout.androidaps.setupwizard.SetupWizardActivity
@Suppress("unused") @Suppress("unused")
abstract class ActivitiesModule { abstract class ActivitiesModule {
@ContributesAndroidInjector abstract fun contributesTreatmentsActivity(): TreatmentsActivity
@ContributesAndroidInjector abstract fun contributesHistoryBrowseActivity(): HistoryBrowseActivity @ContributesAndroidInjector abstract fun contributesHistoryBrowseActivity(): HistoryBrowseActivity
@ContributesAndroidInjector abstract fun contributesLogSettingActivity(): LogSettingActivity @ContributesAndroidInjector abstract fun contributesLogSettingActivity(): LogSettingActivity
@ContributesAndroidInjector abstract fun contributeMainActivity(): MainActivity @ContributesAndroidInjector abstract fun contributeMainActivity(): MainActivity

View file

@ -3,13 +3,6 @@ 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.activities.fragments.TreatmentsBolusCarbsFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsCareportalFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsExtendedBolusesFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsProfileSwitchFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsTempTargetFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsTemporaryBasalsFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsUserEntryFragment
import info.nightscout.androidaps.dialogs.ExtendedBolusDialog import info.nightscout.androidaps.dialogs.ExtendedBolusDialog
import info.nightscout.androidaps.dialogs.FillDialog import info.nightscout.androidaps.dialogs.FillDialog
import info.nightscout.androidaps.dialogs.InsulinDialog import info.nightscout.androidaps.dialogs.InsulinDialog
@ -20,7 +13,6 @@ import info.nightscout.androidaps.dialogs.TempBasalDialog
import info.nightscout.androidaps.dialogs.TempTargetDialog import info.nightscout.androidaps.dialogs.TempTargetDialog
import info.nightscout.androidaps.dialogs.TreatmentDialog import info.nightscout.androidaps.dialogs.TreatmentDialog
import info.nightscout.androidaps.dialogs.WizardDialog import info.nightscout.androidaps.dialogs.WizardDialog
import info.nightscout.androidaps.dialogs.WizardInfoDialog
import info.nightscout.androidaps.plugins.aps.OpenAPSFragment import info.nightscout.androidaps.plugins.aps.OpenAPSFragment
import info.nightscout.androidaps.plugins.aps.loop.LoopFragment import info.nightscout.androidaps.plugins.aps.loop.LoopFragment
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment
@ -57,13 +49,6 @@ abstract class FragmentsModule {
@ContributesAndroidInjector abstract fun contributesWearFragment(): WearFragment @ContributesAndroidInjector abstract fun contributesWearFragment(): WearFragment
@ContributesAndroidInjector abstract fun contributesTidepoolFragment(): TidepoolFragment @ContributesAndroidInjector abstract fun contributesTidepoolFragment(): TidepoolFragment
@ContributesAndroidInjector abstract fun contributesTreatmentsBolusFragment(): TreatmentsBolusCarbsFragment
@ContributesAndroidInjector abstract fun contributesTreatmentsTemporaryBasalsFragment(): TreatmentsTemporaryBasalsFragment
@ContributesAndroidInjector abstract fun contributesTreatmentsTempTargetFragment(): TreatmentsTempTargetFragment
@ContributesAndroidInjector abstract fun contributesTreatmentsExtendedBolusesFragment(): TreatmentsExtendedBolusesFragment
@ContributesAndroidInjector abstract fun contributesTreatmentsCareportalFragment(): TreatmentsCareportalFragment
@ContributesAndroidInjector abstract fun contributesTreatmentsProfileSwitchFragment(): TreatmentsProfileSwitchFragment
@ContributesAndroidInjector abstract fun contributesTreatmentsUserEntryFragment(): TreatmentsUserEntryFragment
@ContributesAndroidInjector abstract fun contributesVirtualPumpFragment(): VirtualPumpFragment @ContributesAndroidInjector abstract fun contributesVirtualPumpFragment(): VirtualPumpFragment
@ -79,7 +64,6 @@ abstract class FragmentsModule {
@ContributesAndroidInjector abstract fun contributesTempTargetDialog(): TempTargetDialog @ContributesAndroidInjector abstract fun contributesTempTargetDialog(): TempTargetDialog
@ContributesAndroidInjector abstract fun contributesTreatmentDialog(): TreatmentDialog @ContributesAndroidInjector abstract fun contributesTreatmentDialog(): TreatmentDialog
@ContributesAndroidInjector abstract fun contributesWizardDialog(): WizardDialog @ContributesAndroidInjector abstract fun contributesWizardDialog(): WizardDialog
@ContributesAndroidInjector abstract fun contributesWizardInfoDialog(): WizardInfoDialog
@ContributesAndroidInjector abstract fun contributesNtpProgressDialog(): NtpProgressDialog @ContributesAndroidInjector abstract fun contributesNtpProgressDialog(): NtpProgressDialog
@ContributesAndroidInjector abstract fun contributesPasswordCheck(): PasswordCheck @ContributesAndroidInjector abstract fun contributesPasswordCheck(): PasswordCheck
} }

View file

@ -1,3 +1,2 @@
package info.nightscout.androidaps.events package info.nightscout.androidaps.events
class EventTempTargetChange : Event()

View file

@ -14,7 +14,7 @@ import info.nightscout.androidaps.interfaces.DataSyncSelector
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.plugins.general.nsclient.events.EventNSClientRestart import info.nightscout.androidaps.events.EventNSClientRestart
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.alertDialogs.OKDialog

View file

@ -4,7 +4,7 @@ import info.nightscout.androidaps.events.Event
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.plugins.general.nsclient.events.EventNSClientRestart import info.nightscout.androidaps.events.EventNSClientRestart
import io.socket.client.Ack import io.socket.client.Ack
import org.json.JSONArray import org.json.JSONArray
import org.json.JSONObject import org.json.JSONObject

View file

@ -33,7 +33,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.data.NSAlarm
import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog
import info.nightscout.plugins.general.nsclient.events.EventNSClientRestart import info.nightscout.androidaps.events.EventNSClientRestart
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientStatus import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientStatus
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification

View file

@ -17,6 +17,7 @@ import info.nightscout.androidaps.events.Event
import info.nightscout.androidaps.events.EventConfigBuilderChange import info.nightscout.androidaps.events.EventConfigBuilderChange
import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged
import info.nightscout.androidaps.events.EventNewBG import info.nightscout.androidaps.events.EventNewBG
import info.nightscout.androidaps.events.EventNewHistoryData
import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.iobCalc import info.nightscout.androidaps.extensions.iobCalc
@ -32,7 +33,6 @@ import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.overview.OverviewData import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy

View file

@ -2,27 +2,32 @@ package info.nightscout.androidaps.workflow
import android.content.Context import android.content.Context
import android.os.SystemClock import android.os.SystemClock
import androidx.work.* import androidx.work.Data
import androidx.work.ExistingWorkPolicy
import androidx.work.OneTimeWorkRequest
import androidx.work.WorkContinuation
import androidx.work.WorkInfo
import androidx.work.WorkManager
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.Event import info.nightscout.androidaps.events.Event
import info.nightscout.androidaps.events.EventAppInitialized import info.nightscout.androidaps.events.EventAppInitialized
import info.nightscout.androidaps.events.EventNewHistoryData
import info.nightscout.androidaps.events.EventOfflineChange import info.nightscout.androidaps.events.EventOfflineChange
import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.events.EventTherapyEventChange import info.nightscout.androidaps.events.EventTherapyEventChange
import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.IobCobCalculator import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.overview.OverviewData import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Worker import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Worker
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOrefWorker import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOrefWorker
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
import info.nightscout.androidaps.receivers.DataWorkerStorage import info.nightscout.androidaps.receivers.DataWorkerStorage
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag

View file

@ -85,19 +85,6 @@
<string name="description_source_xdrip">Receive BG values from xDrip+.</string> <string name="description_source_xdrip">Receive BG values from xDrip+.</string>
<string name="description_treatments">Saves all treatments that were made</string> <string name="description_treatments">Saves all treatments that were made</string>
<string name="description_wear">Monitor and control AAPS using your WearOS watch.</string> <string name="description_wear">Monitor and control AAPS using your WearOS watch.</string>
<string name="treatments_insulin_label_string">Insulin:</string>
<string name="treatments_carbs_label_string">Carbs:</string>
<string name="treatments_iob_label_string">IOB:</string>
<string name="treatments_iobtotal_label_string">Total IOB:</string>
<string name="treatments_iobactivitytotal_label_string">Total IOB activity:</string>
<string name="tempbasals_realduration_label_string">Dur:</string>
<string name="tempbasals_netratio_label_string">Ratio:</string>
<string name="tempbasals_netinsulin_label_string">Ins:</string>
<string name="tempbasals_iob_label_string">IOB:</string>
<string name="tempbasals_iobtotal_label_string">Total IOB:</string>
<string name="treatments_wizard_tt_label">TT</string>
<string name="treatments_wizard_correction_label">Corr</string>
<string name="bolus_iob_label">Bolus IOB</string>
<string name="openapsma_run">Run now</string> <string name="openapsma_run">Run now</string>
<string name="vitualpump_label">VIRTUAL PUMP</string> <string name="vitualpump_label">VIRTUAL PUMP</string>
<string name="openapsma_lastrun_label">Last run</string> <string name="openapsma_lastrun_label">Last run</string>
@ -136,7 +123,6 @@
<string name="openapsma_disabled">Plugin is disabled</string> <string name="openapsma_disabled">Plugin is disabled</string>
<string name="constraints_violation">Constraints violation</string> <string name="constraints_violation">Constraints violation</string>
<string name="setbasalquestion">Accept new temp basal:</string> <string name="setbasalquestion">Accept new temp basal:</string>
<string name="overview_treatment_label">Treatment</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>
@ -148,7 +134,6 @@
<string name="openloop_newsuggestion">New suggestion available</string> <string name="openloop_newsuggestion">New suggestion available</string>
<string name="carbssuggestion">Carbs Suggestion</string> <string name="carbssuggestion">Carbs Suggestion</string>
<string name="unsupportednsversion">Unsupported version of Nightscout</string> <string name="unsupportednsversion">Unsupported version of Nightscout</string>
<string name="treatments_wizard_basaliob_label">Basal IOB</string>
<string name="carb_time_label">Carb time</string> <string name="carb_time_label">Carb time</string>
<string name="profile_label">Profile</string> <string name="profile_label">Profile</string>
<string name="overview_tempbasal_button">TempBasal</string> <string name="overview_tempbasal_button">TempBasal</string>
@ -196,7 +181,6 @@
<string name="overview_editquickwizard_valid">Valid:</string> <string name="overview_editquickwizard_valid">Valid:</string>
<string name="overview_editquickwizardlistactivity_add">Add</string> <string name="overview_editquickwizardlistactivity_add">Add</string>
<string name="overview_quickwizard_item_edit_button">Edit</string> <string name="overview_quickwizard_item_edit_button">Edit</string>
<string name="mealbolus">Meal</string>
<string name="correctionbous">Corr</string> <string name="correctionbous">Corr</string>
<string name="actions">Actions</string> <string name="actions">Actions</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>
@ -225,8 +209,6 @@
<string name="openapsma_autosensdata_label">Autosens data</string> <string name="openapsma_autosensdata_label">Autosens data</string>
<string name="openapsma_scriptdebugdata_label">Script debug</string> <string name="openapsma_scriptdebugdata_label">Script debug</string>
<string name="openapsama_useautosens">Use Autosens feature</string> <string name="openapsama_useautosens">Use Autosens feature</string>
<string name="refresheventsfromnightscout">Refresh from NS</string>
<string name="deletefuturetreatments">Delete treatments in the future</string>
<string name="actions_shortname">ACT</string> <string name="actions_shortname">ACT</string>
<string name="configbuilder_shortname">CONF</string> <string name="configbuilder_shortname">CONF</string>
<string name="loop_shortname">LOOP</string> <string name="loop_shortname">LOOP</string>
@ -305,9 +287,6 @@
<string name="duration10h">10 hours</string> <string name="duration10h">10 hours</string>
<string name="resume">Resume</string> <string name="resume">Resume</string>
<string name="reconnect">Reconnect Pump</string> <string name="reconnect">Reconnect Pump</string>
<string name="bg_trend_label">15min trend</string>
<string name="treatments_wizard_cob_label">COB</string>
<string name="superbolus">Superbolus</string>
<string name="ns_logappstartedevent">Log app start to NS</string> <string name="ns_logappstartedevent">Log app start to NS</string>
<string name="restartingapp">Exiting application to apply settings.</string> <string name="restartingapp">Exiting application to apply settings.</string>
<string name="configbuilder_insulin_description">Which type of insulin are you using?</string> <string name="configbuilder_insulin_description">Which type of insulin are you using?</string>
@ -597,7 +576,6 @@
<string name="virtualpump_type">Virtual Pump Type</string> <string name="virtualpump_type">Virtual Pump Type</string>
<string name="virtualpump_definition">Pump Definition</string> <string name="virtualpump_definition">Pump Definition</string>
<string name="virtualpump_pump_def">Bolus: Step=%1$s\nExtended Bolus: [Step=%2$s, Duration=%3$smin-%4$sh]\nBasal: Step=%5$s\nTBR: %6$s (by %7$s), Duration=%8$smin-%9$sh\n%10$s</string> <string name="virtualpump_pump_def">Bolus: Step=%1$s\nExtended Bolus: [Step=%2$s, Duration=%3$smin-%4$sh]\nBasal: Step=%5$s\nTBR: %6$s (by %7$s), Duration=%8$smin-%9$sh\n%10$s</string>
<string name="wear_wizard_settings">Wizard Settings</string>
<string name="key_wearwizard_bg" translatable="false">wearwizard_bg</string> <string name="key_wearwizard_bg" translatable="false">wearwizard_bg</string>
<string name="key_wearwizard_tt" translatable="false">wearwizard_tt</string> <string name="key_wearwizard_tt" translatable="false">wearwizard_tt</string>
<string name="key_wearwizard_trend" translatable="false">wearwizard_trend</string> <string name="key_wearwizard_trend" translatable="false">wearwizard_trend</string>
@ -644,9 +622,6 @@
<string name="sensitivity_raises_target_title">Sensitivity raises target</string> <string name="sensitivity_raises_target_title">Sensitivity raises target</string>
<string name="sensitivity_raises_target_summary">When sensitivity is detected, raise the target glucose</string> <string name="sensitivity_raises_target_summary">When sensitivity is detected, raise the target glucose</string>
<string name="key_keep_screen_on" translatable="false">keep_screen_on</string> <string name="key_keep_screen_on" translatable="false">keep_screen_on</string>
<string name="careportal_removestartedevents">Remove AAPS started entries</string>
<string name="show_invalidated">Show invalidated</string>
<string name="hide_invalidated">Hide invalidated</string>
<string name="remove_items">Remove items</string> <string name="remove_items">Remove items</string>
<string name="sort_items">Sort items</string> <string name="sort_items">Sort items</string>
<string name="storedsettingsfound">Stored settings found</string> <string name="storedsettingsfound">Stored settings found</string>
@ -673,8 +648,6 @@
<string name="nsmalfunction">NSClient malfunction. Consider NS and NSClient restart.</string> <string name="nsmalfunction">NSClient malfunction. Consider NS and NSClient restart.</string>
<string name="key_aps_mode" translatable="false">aps_mode</string> <string name="key_aps_mode" translatable="false">aps_mode</string>
<string name="setupwizard_preferred_aps_mode">Preferred APS mode</string> <string name="setupwizard_preferred_aps_mode">Preferred APS mode</string>
<string name="treatments_wizard_total_label">Total</string>
<string name="calculation_short">Calc</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">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="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>
@ -725,10 +698,6 @@
<string name="partialboluswizard">Deliver this part of bolus wizard result [%]</string> <string name="partialboluswizard">Deliver this part of bolus wizard result [%]</string>
<string name="deliverpartofboluswizard">Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm.</string> <string name="deliverpartofboluswizard">Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm.</string>
<string name="increasingmaxbasal">Increasing max basal value because setting is lower than your max basal in profile</string> <string name="increasingmaxbasal">Increasing max basal value because setting is lower than your max basal in profile</string>
<string name="format_bg_isf">%1$s ISF: %2$.1f</string>
<string name="format_carbs_ic">%1$.0fg IC: %2$.1f</string>
<string name="format_cob_ic">%1$.1fg IC: %2$.1f</string>
<string name="format_percent">%1$d%%</string>
<string name="selected_profile">Selected:</string> <string name="selected_profile">Selected:</string>
<string name="unitsnosemicolon">Units</string> <string name="unitsnosemicolon">Units</string>
<string name="key_wizard_calculation_visible" translatable="false">wizard_calculation_visible</string> <string name="key_wizard_calculation_visible" translatable="false">wizard_calculation_visible</string>
@ -739,7 +708,6 @@
<string name="setupwizard_units_prompt">Select units you want to display values in</string> <string name="setupwizard_units_prompt">Select units you want to display values in</string>
<string name="key_wear_detailediob" translatable="false">wear_detailediob</string> <string name="key_wear_detailediob" translatable="false">wear_detailediob</string>
<string name="key_wear_showbgi" translatable="false">wear_showbgi</string> <string name="key_wear_showbgi" translatable="false">wear_showbgi</string>
<string name="copytolocalprofile">Create new profile from this profile?</string>
<string name="low_mark_comment">Lower value of in range area (display only)</string> <string name="low_mark_comment">Lower value of in range area (display only)</string>
<string name="high_mark_comment">Higher value of in range area (display only)</string> <string name="high_mark_comment">Higher value of in range area (display only)</string>
<string name="invalidpct">Invalid % entry</string> <string name="invalidpct">Invalid % entry</string>
@ -803,7 +771,6 @@
<string name="chart_menu">Chart menu</string> <string name="chart_menu">Chart menu</string>
<string name="clear_filter">Clear filter</string> <string name="clear_filter">Clear filter</string>
<string name="cannula">Cannula</string> <string name="cannula">Cannula</string>
<string name="userentry">User entry</string>
<string name="common_values">Use values of your largest food you usually eat\n</string> <string name="common_values">Use values of your largest food you usually eat\n</string>
<string name="summary_email_for_crash_report">This identification will attached to crash reports so we can contact you in urgent cases. It\'s optional.</string> <string name="summary_email_for_crash_report">This identification will attached to crash reports so we can contact you in urgent cases. It\'s optional.</string>
<string name="email_address">Email address</string> <string name="email_address">Email address</string>
@ -811,31 +778,24 @@
<string name="privacy_summary">You can provide optional email address if you want to be notified about app crashes. This is not an automated service. You will be contacted by developers in dangerous situations.</string> <string name="privacy_summary">You can provide optional email address if you want to be notified about app crashes. This is not an automated service. You will be contacted by developers in dangerous situations.</string>
<string name="full_sync">Full synchronization</string> <string name="full_sync">Full synchronization</string>
<string name="full_sync_comment">Full synchronization? It may take many hours and until finish you\'ll not see new data in NS.</string> <string name="full_sync_comment">Full synchronization? It may take many hours and until finish you\'ll not see new data in NS.</string>
<string name="prime">Prime</string>
<string name="ns_sync_options">Synchronization</string> <string name="ns_sync_options">Synchronization</string>
<string name="key_ns_upload" translatable="false">ns_upload</string> <string name="key_ns_upload" translatable="false">ns_upload</string>
<string name="ns_upload_summary">Profiles, boluses, carbs, temporary basals are uploaded to NS</string> <string name="ns_upload_summary">Profiles, boluses, carbs, temporary basals are uploaded to NS</string>
<string name="ns_upload">Upload data to NS</string> <string name="ns_upload">Upload data to NS</string>
<string name="ns_receive_profile_store">Receive profile store</string> <string name="ns_receive_profile_store">Receive profile store</string>
<string name="ns_receive_profile_store_summary">Synchronize profiles from NS profile editor</string> <string name="ns_receive_profile_store_summary">Synchronize profiles from NS profile editor</string>
<string name="key_ns_receive_temp_target" translatable="false">ns_receive_temp_target</string>
<string name="ns_receive_temp_target">Receive temporary targets</string> <string name="ns_receive_temp_target">Receive temporary targets</string>
<string name="ns_receive_temp_target_summary">Accept temporary targets entered through NS or NSClient</string> <string name="ns_receive_temp_target_summary">Accept temporary targets entered through NS or NSClient</string>
<string name="key_ns_receive_profile_switch" translatable="false">ns_receive_profile_switch</string>
<string name="key_ns_receive_offline_event" translatable="false">ns_receive_offline_event</string>
<string name="ns_receive_profile_switch">Receive profile switches</string> <string name="ns_receive_profile_switch">Receive profile switches</string>
<string name="ns_receive_profile_switch_summary">Accept profile switches entered through NS or NSClient</string> <string name="ns_receive_profile_switch_summary">Accept profile switches entered through NS or NSClient</string>
<string name="ns_receive_offline_event">Receive APS offline events</string> <string name="ns_receive_offline_event">Receive APS offline events</string>
<string name="ns_receive_offline_event_summary">Accept APS Offline events entered through NS or NSClient</string> <string name="ns_receive_offline_event_summary">Accept APS Offline events entered through NS or NSClient</string>
<string name="ns_receive_tbr_eb">Receive TBR and EB</string> <string name="ns_receive_tbr_eb">Receive TBR and EB</string>
<string name="ns_receive_tbr_eb_summary">Accept TBR and EB entered through another instance</string> <string name="ns_receive_tbr_eb_summary">Accept TBR and EB entered through another instance</string>
<string name="key_ns_receive_insulin" translatable="false">ns_receive_insulin</string>
<string name="ns_receive_insulin">Receive insulin</string> <string name="ns_receive_insulin">Receive insulin</string>
<string name="ns_receive_insulin_summary">Accept insulin entered through NS or NSClient (it\'s not delivered, only calculated towards IOB)</string> <string name="ns_receive_insulin_summary">Accept insulin entered through NS or NSClient (it\'s not delivered, only calculated towards IOB)</string>
<string name="key_ns_receive_carbs" translatable="false">ns_receive_carbs</string>
<string name="ns_receive_carbs">Receive carbs</string> <string name="ns_receive_carbs">Receive carbs</string>
<string name="ns_receive_carbs_summary">Accept carbs entered through NS or NSClient</string> <string name="ns_receive_carbs_summary">Accept carbs entered through NS or NSClient</string>
<string name="key_ns_receive_therapy_events" translatable="false">ns_receive_therapy_events</string>
<string name="key_ns_receive_tbr_eb" translatable="false">ns_receive_tbr_eb</string> <string name="key_ns_receive_tbr_eb" translatable="false">ns_receive_tbr_eb</string>
<string name="ns_receive_therapy_events">Receive therapy events</string> <string name="ns_receive_therapy_events">Receive therapy events</string>
<string name="ns_receive_therapy_events_summary">Accept therapy events (cannula, insulin, battery change etc) entered through NS or NSClient</string> <string name="ns_receive_therapy_events_summary">Accept therapy events (cannula, insulin, battery change etc) entered through NS or NSClient</string>
@ -896,22 +856,9 @@
<string name="wear_unknown_action_string">Unknown action command:</string> <string name="wear_unknown_action_string">Unknown action command:</string>
<string name="overview_editquickwizard_percentage">Percentage</string> <string name="overview_editquickwizard_percentage">Percentage</string>
<string name="app_default">Application default</string> <string name="app_default">Application default</string>
<string name="show_invalidated_records">Show invalidated / removed records</string>
<string name="hide_invalidated_records">Hide invalidated / removed records</string>
<string name="refresh_from_nightscout">Refresh from Nightscout</string>
<string name="remove_selected_items">Remove selected items</string> <string name="remove_selected_items">Remove selected items</string>
<string name="select_for_removal">Select for removal</string>
<string name="profile_changes">Profile changes</string>
<string name="tempt_targets">Temp Targets</string>
<string name="carbs_and_bolus">Carbs and bolus</string>
<string name="confirm_remove_multiple_items">Are you sure you want to remove %1$d items</string>
<string name="no_records_available">No records available</string>
<string name="hide_loop">Hide loop</string>
<string name="show_loop">Show loop</string>
<string name="count_selected">%1$d selected</string> <string name="count_selected">%1$d selected</string>
<string name="sort_label">Sort</string> <string name="sort_label">Sort</string>
<string name="show_loop_records">Show loop records</string>
<string name="show_hide_records">Hide loop records</string>
<string name="loop_status">Loop status</string> <string name="loop_status">Loop status</string>
<string name="graph_scale">Graph scale</string> <string name="graph_scale">Graph scale</string>
<string name="profile1">Profile 1</string> <string name="profile1">Profile 1</string>

View file

@ -0,0 +1,3 @@
package info.nightscout.androidaps.events
class EventLocalProfileChanged : Event()

View file

@ -0,0 +1,3 @@
package info.nightscout.androidaps.events
class EventNSClientRestart : Event()

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.iob.iobCobCalculator.events package info.nightscout.androidaps.events
import info.nightscout.androidaps.database.entities.GlucoseValue import info.nightscout.androidaps.database.entities.GlucoseValue
import info.nightscout.androidaps.events.Event
import org.joda.time.DateTime import org.joda.time.DateTime
import org.joda.time.format.DateTimeFormat import org.joda.time.format.DateTimeFormat
import java.text.DateFormat import java.text.DateFormat

View file

@ -0,0 +1,3 @@
package info.nightscout.androidaps.events
class EventTempTargetChange : Event()

View file

@ -1,3 +1,3 @@
package info.nightscout.androidaps.events package info.nightscout.androidaps.events
class EventTherapyEventChange : Event() class EventTherapyEventChange : Event()

View file

@ -1,7 +1,38 @@
package info.nightscout.androidaps.interfaces package info.nightscout.androidaps.interfaces
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.data.PureProfile
import org.json.JSONArray
interface ProfileSource { interface ProfileSource {
class SingleProfile {
var name: String? = null
var mgdl: Boolean = false
var dia: Double = Constants.defaultDIA
var ic: JSONArray? = null
var isf: JSONArray? = null
var basal: JSONArray? = null
var targetLow: JSONArray? = null
var targetHigh: JSONArray? = null
fun deepClone(): SingleProfile {
val sp = SingleProfile()
sp.name = name
sp.mgdl = mgdl
sp.dia = dia
sp.ic = JSONArray(ic.toString())
sp.isf = JSONArray(isf.toString())
sp.basal = JSONArray(basal.toString())
sp.targetLow = JSONArray(targetLow.toString())
sp.targetHigh = JSONArray(targetHigh.toString())
return sp
}
}
val profile: ProfileStore? val profile: ProfileStore?
val profileName: String? val profileName: String?
fun addProfile(p: SingleProfile)
fun copyFrom(pureProfile: PureProfile, newName: String): SingleProfile
} }

View file

@ -88,6 +88,12 @@
<string name="key_ns_receive_profile_store" translatable="false">ns_receive_profile_store</string> <string name="key_ns_receive_profile_store" translatable="false">ns_receive_profile_store</string>
<string name="key_nsclientinternal_url" translatable="false">nsclientinternal_url</string> <string name="key_nsclientinternal_url" translatable="false">nsclientinternal_url</string>
<string name="key_nsclientinternal_api_secret" translatable="false">nsclientinternal_api_secret</string> <string name="key_nsclientinternal_api_secret" translatable="false">nsclientinternal_api_secret</string>
<string name="key_ns_receive_insulin" translatable="false">ns_receive_insulin</string>
<string name="key_ns_receive_carbs" translatable="false">ns_receive_carbs</string>
<string name="key_ns_receive_therapy_events" translatable="false">ns_receive_therapy_events</string>
<string name="key_ns_receive_profile_switch" translatable="false">ns_receive_profile_switch</string>
<string name="key_ns_receive_offline_event" translatable="false">ns_receive_offline_event</string>
<string name="key_ns_receive_temp_target" translatable="false">ns_receive_temp_target</string>
<!-- General--> <!-- General-->
<string name="refresh">Refresh</string> <string name="refresh">Refresh</string>
@ -237,6 +243,15 @@
<string name="reset">reset</string> <string name="reset">reset</string>
<string name="profileswitch_ismissing">ProfileSwitch missing. Please do a profile switch or press \"Activate Profile\" in the LocalProfile.</string> <string name="profileswitch_ismissing">ProfileSwitch missing. Please do a profile switch or press \"Activate Profile\" in the LocalProfile.</string>
<string name="profile">Profile</string> <string name="profile">Profile</string>
<string name="select_for_removal">Select for removal</string>
<string name="confirm_remove_multiple_items">Are you sure you want to remove %1$d items</string>
<string name="overview_treatment_label">Treatment</string>
<string name="copytolocalprofile">Create new profile from this profile?</string>
<string name="wear_wizard_settings">Wizard Settings</string>
<string name="bg_trend_label">15min trend</string>
<string name="treatments_wizard_cob_label">COB</string>
<string name="bolus_iob_label">Bolus IOB</string>
<string name="treatments_wizard_basaliob_label">Basal IOB</string>
<!-- Constraints--> <!-- Constraints-->
<string name="limitingbasalratio">Limiting max basal rate to %1$.2f U/h because of %2$s</string> <string name="limitingbasalratio">Limiting max basal rate to %1$.2f U/h because of %2$s</string>

View file

@ -46,7 +46,7 @@ import info.nightscout.plugins.databinding.AutotuneFragmentBinding
import info.nightscout.plugins.general.autotune.data.ATProfile import info.nightscout.plugins.general.autotune.data.ATProfile
import info.nightscout.plugins.general.autotune.events.EventAutotuneUpdateGui import info.nightscout.plugins.general.autotune.events.EventAutotuneUpdateGui
import info.nightscout.plugins.profile.ProfilePlugin import info.nightscout.plugins.profile.ProfilePlugin
import info.nightscout.plugins.profile.events.EventLocalProfileChanged import info.nightscout.androidaps.events.EventLocalProfileChanged
import info.nightscout.shared.SafeParse import info.nightscout.shared.SafeParse
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable

View file

@ -29,7 +29,7 @@ import info.nightscout.plugins.general.autotune.data.ATProfile
import info.nightscout.plugins.general.autotune.data.PreppedGlucose import info.nightscout.plugins.general.autotune.data.PreppedGlucose
import info.nightscout.plugins.general.autotune.events.EventAutotuneUpdateGui import info.nightscout.plugins.general.autotune.events.EventAutotuneUpdateGui
import info.nightscout.plugins.profile.ProfilePlugin import info.nightscout.plugins.profile.ProfilePlugin
import info.nightscout.plugins.profile.events.EventLocalProfileChanged import info.nightscout.androidaps.events.EventLocalProfileChanged
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP

View file

@ -1,5 +0,0 @@
package info.nightscout.plugins.general.nsclient.events
import info.nightscout.androidaps.events.Event
class EventNSClientRestart : Event()

View file

@ -12,7 +12,6 @@ import androidx.work.WorkerParameters
import androidx.work.workDataOf import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.plugins.R
import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.Sms import info.nightscout.androidaps.data.Sms
@ -26,35 +25,53 @@ import info.nightscout.androidaps.database.transactions.CancelCurrentOfflineEven
import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
import info.nightscout.androidaps.database.transactions.InsertAndCancelCurrentOfflineEventTransaction import info.nightscout.androidaps.database.transactions.InsertAndCancelCurrentOfflineEventTransaction
import info.nightscout.androidaps.database.transactions.InsertAndCancelCurrentTemporaryTargetTransaction import info.nightscout.androidaps.database.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
import info.nightscout.androidaps.events.EventNSClientRestart
import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.extensions.valueToUnitsString import info.nightscout.androidaps.extensions.valueToUnitsString
import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.Loop
import info.nightscout.androidaps.interfaces.PluginBase
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.PumpSync
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.interfaces.SmsCommunicator
import info.nightscout.androidaps.interfaces.XDripBroadcast
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
import info.nightscout.plugins.general.smsCommunicator.events.EventSmsCommunicatorUpdateGui
import info.nightscout.plugins.general.smsCommunicator.otp.OneTimePassword
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.receivers.DataWorkerStorage import info.nightscout.androidaps.receivers.DataWorkerStorage
import info.nightscout.androidaps.utils.* import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference import info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
import info.nightscout.plugins.general.nsclient.events.EventNSClientRestart import info.nightscout.plugins.R
import info.nightscout.plugins.general.smsCommunicator.events.EventSmsCommunicatorUpdateGui
import info.nightscout.plugins.general.smsCommunicator.otp.OneTimePassword
import info.nightscout.shared.SafeParse import info.nightscout.shared.SafeParse
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.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import org.apache.commons.lang3.StringUtils import org.apache.commons.lang3.StringUtils
import org.joda.time.DateTime import org.joda.time.DateTime
import java.text.Normalizer import java.text.Normalizer
import java.util.* import java.util.Locale
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import java.util.regex.Pattern import java.util.regex.Pattern
import javax.inject.Inject import javax.inject.Inject
@ -86,14 +103,15 @@ class SmsCommunicatorPlugin @Inject constructor(
private val uel: UserEntryLogger, private val uel: UserEntryLogger,
private val glucoseStatusProvider: GlucoseStatusProvider, private val glucoseStatusProvider: GlucoseStatusProvider,
private val repository: AppRepository private val repository: AppRepository
) : PluginBase(PluginDescription() ) : PluginBase(
.mainType(PluginType.GENERAL) PluginDescription()
.fragmentClass(SmsCommunicatorFragment::class.java.name) .mainType(PluginType.GENERAL)
.pluginIcon(R.drawable.ic_sms) .fragmentClass(SmsCommunicatorFragment::class.java.name)
.pluginName(R.string.smscommunicator) .pluginIcon(R.drawable.ic_sms)
.shortName(R.string.smscommunicator_shortname) .pluginName(R.string.smscommunicator)
.preferencesId(R.xml.pref_smscommunicator) .shortName(R.string.smscommunicator_shortname)
.description(R.string.description_sms_communicator), .preferencesId(R.xml.pref_smscommunicator)
.description(R.string.description_sms_communicator),
aapsLogger, rh, injector aapsLogger, rh, injector
), SmsCommunicator { ), SmsCommunicator {
@ -255,29 +273,36 @@ class SmsCommunicatorPlugin @Inject constructor(
"BG" -> "BG" ->
if (divided.size == 1) processBG(receivedSms) if (divided.size == 1) processBG(receivedSms)
else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
"LOOP" -> "LOOP" ->
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed))) if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed)))
else if (divided.size == 2 || divided.size == 3) processLOOP(divided, receivedSms) else if (divided.size == 2 || divided.size == 3) processLOOP(divided, receivedSms)
else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
"NSCLIENT" -> "NSCLIENT" ->
if (divided.size == 2) processNSCLIENT(divided, receivedSms) if (divided.size == 2) processNSCLIENT(divided, receivedSms)
else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
"PUMP" -> "PUMP" ->
if (!remoteCommandsAllowed && divided.size > 1) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed))) if (!remoteCommandsAllowed && divided.size > 1) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed)))
else if (divided.size <= 3) processPUMP(divided, receivedSms) else if (divided.size <= 3) processPUMP(divided, receivedSms)
else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
"PROFILE" -> "PROFILE" ->
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed))) if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed)))
else if (divided.size == 2 || divided.size == 3) processPROFILE(divided, receivedSms) else if (divided.size == 2 || divided.size == 3) processPROFILE(divided, receivedSms)
else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
"BASAL" -> "BASAL" ->
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed))) if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed)))
else if (divided.size == 2 || divided.size == 3) processBASAL(divided, receivedSms) else if (divided.size == 2 || divided.size == 3) processBASAL(divided, receivedSms)
else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
"EXTENDED" -> "EXTENDED" ->
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed))) if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed)))
else if (divided.size == 2 || divided.size == 3) processEXTENDED(divided, receivedSms) else if (divided.size == 2 || divided.size == 3) processEXTENDED(divided, receivedSms)
else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
"BOLUS" -> "BOLUS" ->
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed))) if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed)))
else if (commandQueue.bolusInQueue()) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_another_bolus_in_queue))) else if (commandQueue.bolusInQueue()) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_another_bolus_in_queue)))
@ -285,25 +310,31 @@ class SmsCommunicatorPlugin @Inject constructor(
else if (divided.size == 2 && pump.isSuspended()) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.pumpsuspended))) else if (divided.size == 2 && pump.isSuspended()) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.pumpsuspended)))
else if (divided.size == 2 || divided.size == 3) processBOLUS(divided, receivedSms) else if (divided.size == 2 || divided.size == 3) processBOLUS(divided, receivedSms)
else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
"CARBS" -> "CARBS" ->
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed))) if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed)))
else if (divided.size == 2 || divided.size == 3) processCARBS(divided, receivedSms) else if (divided.size == 2 || divided.size == 3) processCARBS(divided, receivedSms)
else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
"CAL" -> "CAL" ->
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed))) if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed)))
else if (divided.size == 2) processCAL(divided, receivedSms) else if (divided.size == 2) processCAL(divided, receivedSms)
else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
"TARGET" -> "TARGET" ->
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed))) if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed)))
else if (divided.size == 2) processTARGET(divided, receivedSms) else if (divided.size == 2) processTARGET(divided, receivedSms)
else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
"SMS" -> "SMS" ->
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed))) if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_remotecommandnotallowed)))
else if (divided.size == 2) processSMS(divided, receivedSms) else if (divided.size == 2) processSMS(divided, receivedSms)
else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
"HELP" -> "HELP" ->
if (divided.size == 1 || divided.size == 2) processHELP(divided, receivedSms) if (divided.size == 1 || divided.size == 2) processHELP(divided, receivedSms)
else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
else -> else ->
if (messageToConfirm?.requester?.phoneNumber == receivedSms.phoneNumber) { if (messageToConfirm?.requester?.phoneNumber == receivedSms.phoneNumber) {
val execute = messageToConfirm val execute = messageToConfirm
@ -406,10 +437,10 @@ class SmsCommunicatorPlugin @Inject constructor(
uel.log(Action.RESUME, Sources.SMS) uel.log(Action.RESUME, Sources.SMS)
disposable += repository.runTransactionForResult(CancelCurrentOfflineEventIfAnyTransaction(dateUtil.now())) disposable += repository.runTransactionForResult(CancelCurrentOfflineEventIfAnyTransaction(dateUtil.now()))
.subscribe({ result -> .subscribe({ result ->
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated OfflineEvent $it") } result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated OfflineEvent $it") }
}, { }, {
aapsLogger.error(LTag.DATABASE, "Error while saving OfflineEvent", it) aapsLogger.error(LTag.DATABASE, "Error while saving OfflineEvent", it)
}) })
rxBus.send(EventRefreshOverview("SMS_LOOP_RESUME")) rxBus.send(EventRefreshOverview("SMS_LOOP_RESUME"))
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
@ -444,13 +475,19 @@ class SmsCommunicatorPlugin @Inject constructor(
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
if (result.success) { if (result.success) {
disposable += repository.runTransactionForResult(InsertAndCancelCurrentOfflineEventTransaction(dateUtil.now(), T.mins(anInteger().toLong()).msecs(), OfflineEvent.Reason.SUSPEND)) disposable += repository.runTransactionForResult(
InsertAndCancelCurrentOfflineEventTransaction(
dateUtil.now(),
T.mins(anInteger().toLong()).msecs(),
OfflineEvent.Reason.SUSPEND
)
)
.subscribe({ result -> .subscribe({ result ->
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated OfflineEvent $it") } result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated OfflineEvent $it") }
result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted OfflineEvent $it") } result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted OfflineEvent $it") }
}, { }, {
aapsLogger.error(LTag.DATABASE, "Error while saving OfflineEvent", it) aapsLogger.error(LTag.DATABASE, "Error while saving OfflineEvent", it)
}) })
rxBus.send(EventRefreshOverview("SMS_LOOP_SUSPENDED")) rxBus.send(EventRefreshOverview("SMS_LOOP_SUSPENDED"))
val replyText = rh.gs(R.string.smscommunicator_loopsuspended) + " " + val replyText = rh.gs(R.string.smscommunicator_loopsuspended) + " " +
rh.gs(if (result.success) R.string.smscommunicator_tempbasalcanceled else R.string.smscommunicator_tempbasalcancelfailed) rh.gs(if (result.success) R.string.smscommunicator_tempbasalcanceled else R.string.smscommunicator_tempbasalcancelfailed)
@ -527,10 +564,10 @@ class SmsCommunicatorPlugin @Inject constructor(
} else { } else {
disposable += repository.runTransactionForResult(CancelCurrentOfflineEventIfAnyTransaction(dateUtil.now())) disposable += repository.runTransactionForResult(CancelCurrentOfflineEventIfAnyTransaction(dateUtil.now()))
.subscribe({ result -> .subscribe({ result ->
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated OfflineEvent $it") } result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated OfflineEvent $it") }
}, { }, {
aapsLogger.error(LTag.DATABASE, "Error while saving OfflineEvent", it) aapsLogger.error(LTag.DATABASE, "Error while saving OfflineEvent", it)
}) })
sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_reconnect))) sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.smscommunicator_reconnect)))
rxBus.send(EventRefreshOverview("SMS_PUMP_START")) rxBus.send(EventRefreshOverview("SMS_PUMP_START"))
} }
@ -637,14 +674,18 @@ class SmsCommunicatorPlugin @Inject constructor(
var replyText = rh.gs(R.string.smscommunicator_tempbasalcanceled) var replyText = rh.gs(R.string.smscommunicator_tempbasalcanceled)
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalcanceled), uel.log(
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_tempbasalcanceled))) Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalcanceled),
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_tempbasalcanceled))
)
} else { } else {
var replyText = rh.gs(R.string.smscommunicator_tempbasalcancelfailed) var replyText = rh.gs(R.string.smscommunicator_tempbasalcancelfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalcancelfailed), uel.log(
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_tempbasalcancelfailed))) Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalcancelfailed),
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_tempbasalcancelfailed))
)
} }
} }
}) })
@ -669,25 +710,36 @@ class SmsCommunicatorPlugin @Inject constructor(
commandQueue.tempBasalPercent(anInteger(), secondInteger(), true, profile, PumpSync.TemporaryBasalType.NORMAL, object : Callback() { commandQueue.tempBasalPercent(anInteger(), secondInteger(), true, profile, PumpSync.TemporaryBasalType.NORMAL, object : Callback() {
override fun run() { override fun run() {
if (result.success) { if (result.success) {
var replyText = if (result.isPercent) rh.gs(R.string.smscommunicator_tempbasalset_percent, result.percent, result.duration) else rh.gs(R.string.smscommunicator_tempbasalset, result.absolute, result.duration) var replyText =
if (result.isPercent) rh.gs(R.string.smscommunicator_tempbasalset_percent, result.percent, result.duration) else rh.gs(
R.string.smscommunicator_tempbasalset,
result.absolute,
result.duration
)
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
if (result.isPercent) if (result.isPercent)
uel.log(Action.TEMP_BASAL, Sources.SMS, uel.log(
activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalset_percent, result.percent, result.duration), Action.TEMP_BASAL, Sources.SMS,
ValueWithUnit.Percent(result.percent), activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalset_percent, result.percent, result.duration),
ValueWithUnit.Minute(result.duration)) ValueWithUnit.Percent(result.percent),
ValueWithUnit.Minute(result.duration)
)
else else
uel.log(Action.TEMP_BASAL, Sources.SMS, uel.log(
activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalset, result.absolute, result.duration), Action.TEMP_BASAL, Sources.SMS,
ValueWithUnit.UnitPerHour(result.absolute), activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalset, result.absolute, result.duration),
ValueWithUnit.Minute(result.duration)) ValueWithUnit.UnitPerHour(result.absolute),
ValueWithUnit.Minute(result.duration)
)
} else { } else {
var replyText = rh.gs(R.string.smscommunicator_tempbasalfailed) var replyText = rh.gs(R.string.smscommunicator_tempbasalfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalfailed), uel.log(
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_tempbasalfailed))) Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalfailed),
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_tempbasalfailed))
)
} }
} }
}) })
@ -718,19 +770,29 @@ class SmsCommunicatorPlugin @Inject constructor(
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
if (result.isPercent) if (result.isPercent)
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalset_percent, result.percent, result.duration), uel.log(
ValueWithUnit.Percent(result.percent), Action.TEMP_BASAL,
ValueWithUnit.Minute(result.duration)) Sources.SMS,
activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalset_percent, result.percent, result.duration),
ValueWithUnit.Percent(result.percent),
ValueWithUnit.Minute(result.duration)
)
else else
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalset, result.absolute, result.duration), uel.log(
ValueWithUnit.UnitPerHour(result.absolute), Action.TEMP_BASAL,
ValueWithUnit.Minute(result.duration)) Sources.SMS,
activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalset, result.absolute, result.duration),
ValueWithUnit.UnitPerHour(result.absolute),
ValueWithUnit.Minute(result.duration)
)
} else { } else {
var replyText = rh.gs(R.string.smscommunicator_tempbasalfailed) var replyText = rh.gs(R.string.smscommunicator_tempbasalfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalfailed), uel.log(
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_tempbasalfailed))) Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_tempbasalfailed),
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_tempbasalfailed))
)
} }
} }
}) })
@ -757,8 +819,10 @@ class SmsCommunicatorPlugin @Inject constructor(
var replyText = rh.gs(R.string.smscommunicator_extendedcancelfailed) var replyText = rh.gs(R.string.smscommunicator_extendedcancelfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_extendedcanceled), uel.log(
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_extendedcanceled))) Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_extendedcanceled),
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_extendedcanceled))
)
} }
} }
}) })
@ -785,20 +849,28 @@ class SmsCommunicatorPlugin @Inject constructor(
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
if (config.APS) if (config.APS)
uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_extendedset, aDouble, duration) + " / " + rh.gs(R.string.loopsuspended), uel.log(
ValueWithUnit.Insulin(aDouble ?: 0.0), Action.EXTENDED_BOLUS,
ValueWithUnit.Minute(duration), Sources.SMS,
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.loopsuspended))) activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_extendedset, aDouble, duration) + " / " + rh.gs(R.string.loopsuspended),
ValueWithUnit.Insulin(aDouble ?: 0.0),
ValueWithUnit.Minute(duration),
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.loopsuspended))
)
else else
uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_extendedset, aDouble, duration), uel.log(
ValueWithUnit.Insulin(aDouble ?: 0.0), Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_extendedset, aDouble, duration),
ValueWithUnit.Minute(duration)) ValueWithUnit.Insulin(aDouble ?: 0.0),
ValueWithUnit.Minute(duration)
)
} else { } else {
var replyText = rh.gs(R.string.smscommunicator_extendedfailed) var replyText = rh.gs(R.string.smscommunicator_extendedfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_extendedfailed), uel.log(
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_extendedfailed))) Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_extendedfailed),
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_extendedfailed))
)
} }
} }
}) })
@ -844,25 +916,31 @@ class SmsCommunicatorPlugin @Inject constructor(
eatingSoonTTDuration = eatingSoonTTDuration =
if (eatingSoonTTDuration > 0) eatingSoonTTDuration if (eatingSoonTTDuration > 0) eatingSoonTTDuration
else Constants.defaultEatingSoonTTDuration else Constants.defaultEatingSoonTTDuration
var eatingSoonTT = sp.getDouble(R.string.key_eatingsoon_target, if (currentProfile.units == GlucoseUnit.MMOL) Constants.defaultEatingSoonTTmmol else Constants.defaultEatingSoonTTmgdl) var eatingSoonTT =
sp.getDouble(
R.string.key_eatingsoon_target,
if (currentProfile.units == GlucoseUnit.MMOL) Constants.defaultEatingSoonTTmmol else Constants.defaultEatingSoonTTmgdl
)
eatingSoonTT = eatingSoonTT =
when { when {
eatingSoonTT > 0 -> eatingSoonTT eatingSoonTT > 0 -> eatingSoonTT
currentProfile.units == GlucoseUnit.MMOL -> Constants.defaultEatingSoonTTmmol currentProfile.units == GlucoseUnit.MMOL -> Constants.defaultEatingSoonTTmmol
else -> Constants.defaultEatingSoonTTmgdl else -> Constants.defaultEatingSoonTTmgdl
} }
disposable += repository.runTransactionForResult(InsertAndCancelCurrentTemporaryTargetTransaction( disposable += repository.runTransactionForResult(
timestamp = dateUtil.now(), InsertAndCancelCurrentTemporaryTargetTransaction(
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()), timestamp = dateUtil.now(),
reason = TemporaryTarget.Reason.EATING_SOON, duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
lowTarget = Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()), reason = TemporaryTarget.Reason.EATING_SOON,
highTarget = Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()) lowTarget = Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()),
)).subscribe({ result -> highTarget = Profile.toMgdl(eatingSoonTT, profileFunction.getUnits())
result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") } )
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } ).subscribe({ result ->
}, { result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") }
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
}) }, {
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
})
val tt = if (currentProfile.units == GlucoseUnit.MMOL) { val tt = if (currentProfile.units == GlucoseUnit.MMOL) {
DecimalFormatter.to1Decimal(eatingSoonTT) DecimalFormatter.to1Decimal(eatingSoonTT)
} else DecimalFormatter.to0Decimal(eatingSoonTT) } else DecimalFormatter.to0Decimal(eatingSoonTT)
@ -875,8 +953,10 @@ class SmsCommunicatorPlugin @Inject constructor(
var replyText = rh.gs(R.string.smscommunicator_bolusfailed) var replyText = rh.gs(R.string.smscommunicator_bolusfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_bolusfailed), uel.log(
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_bolusfailed))) Action.BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + rh.gs(R.string.smscommunicator_bolusfailed),
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_bolusfailed))
)
} }
} }
}) })
@ -933,14 +1013,18 @@ class SmsCommunicatorPlugin @Inject constructor(
var replyText = rh.gs(R.string.smscommunicator_carbsset, anInteger) var replyText = rh.gs(R.string.smscommunicator_carbsset, anInteger)
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.CARBS, Sources.SMS, activePlugin.activePump.shortStatus(true) + ": " + rh.gs(R.string.smscommunicator_carbsset, anInteger), uel.log(
ValueWithUnit.Gram(anInteger ?: 0)) Action.CARBS, Sources.SMS, activePlugin.activePump.shortStatus(true) + ": " + rh.gs(R.string.smscommunicator_carbsset, anInteger),
ValueWithUnit.Gram(anInteger ?: 0)
)
} else { } else {
var replyText = rh.gs(R.string.smscommunicator_carbsfailed, anInteger) var replyText = rh.gs(R.string.smscommunicator_carbsfailed, anInteger)
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.CARBS, Sources.SMS, activePlugin.activePump.shortStatus(true) + ": " + rh.gs(R.string.smscommunicator_carbsfailed, anInteger), uel.log(
ValueWithUnit.Gram(anInteger ?: 0)) Action.CARBS, Sources.SMS, activePlugin.activePump.shortStatus(true) + ": " + rh.gs(R.string.smscommunicator_carbsfailed, anInteger),
ValueWithUnit.Gram(anInteger ?: 0)
)
} }
} }
}) })
@ -1000,24 +1084,28 @@ class SmsCommunicatorPlugin @Inject constructor(
var tt = sp.getDouble(keyTarget, if (units == GlucoseUnit.MMOL) defaultTargetMMOL else defaultTargetMGDL) var tt = sp.getDouble(keyTarget, if (units == GlucoseUnit.MMOL) defaultTargetMMOL else defaultTargetMGDL)
tt = Profile.toCurrentUnits(profileFunction, tt) tt = Profile.toCurrentUnits(profileFunction, tt)
tt = if (tt > 0) tt else if (units == GlucoseUnit.MMOL) defaultTargetMMOL else defaultTargetMGDL tt = if (tt > 0) tt else if (units == GlucoseUnit.MMOL) defaultTargetMMOL else defaultTargetMGDL
disposable += repository.runTransactionForResult(InsertAndCancelCurrentTemporaryTargetTransaction( disposable += repository.runTransactionForResult(
timestamp = dateUtil.now(), InsertAndCancelCurrentTemporaryTargetTransaction(
duration = TimeUnit.MINUTES.toMillis(ttDuration.toLong()), timestamp = dateUtil.now(),
reason = reason, duration = TimeUnit.MINUTES.toMillis(ttDuration.toLong()),
lowTarget = Profile.toMgdl(tt, profileFunction.getUnits()), reason = reason,
highTarget = Profile.toMgdl(tt, profileFunction.getUnits()) lowTarget = Profile.toMgdl(tt, profileFunction.getUnits()),
)).subscribe({ result -> highTarget = Profile.toMgdl(tt, profileFunction.getUnits())
result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") } )
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } ).subscribe({ result ->
}, { result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") }
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
}) }, {
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
})
val ttString = if (units == GlucoseUnit.MMOL) DecimalFormatter.to1Decimal(tt) else DecimalFormatter.to0Decimal(tt) val ttString = if (units == GlucoseUnit.MMOL) DecimalFormatter.to1Decimal(tt) else DecimalFormatter.to0Decimal(tt)
val replyText = rh.gs(R.string.smscommunicator_tt_set, ttString, ttDuration) val replyText = rh.gs(R.string.smscommunicator_tt_set, ttString, ttDuration)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.TT, Sources.SMS, uel.log(
Action.TT, Sources.SMS,
ValueWithUnit.fromGlucoseUnit(tt, units.asText), ValueWithUnit.fromGlucoseUnit(tt, units.asText),
ValueWithUnit.Minute(ttDuration)) ValueWithUnit.Minute(ttDuration)
)
} }
}) })
} else if (isStop) { } else if (isStop) {
@ -1028,14 +1116,16 @@ class SmsCommunicatorPlugin @Inject constructor(
override fun run() { override fun run() {
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(dateUtil.now())) disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(dateUtil.now()))
.subscribe({ result -> .subscribe({ result ->
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
}, { }, {
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
}) })
val replyText = rh.gs(R.string.smscommunicator_tt_canceled) val replyText = rh.gs(R.string.smscommunicator_tt_canceled)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.CANCEL_TT, Sources.SMS, rh.gs(R.string.smscommunicator_tt_canceled), uel.log(
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_tt_canceled))) Action.CANCEL_TT, Sources.SMS, rh.gs(R.string.smscommunicator_tt_canceled),
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_tt_canceled))
)
} }
}) })
} else } else
@ -1054,8 +1144,10 @@ class SmsCommunicatorPlugin @Inject constructor(
sp.putBoolean(R.string.key_smscommunicator_remote_commands_allowed, false) sp.putBoolean(R.string.key_smscommunicator_remote_commands_allowed, false)
val replyText = rh.gs(R.string.smscommunicator_stoppedsms) val replyText = rh.gs(R.string.smscommunicator_stoppedsms)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.STOP_SMS, Sources.SMS, rh.gs(R.string.smscommunicator_stoppedsms), uel.log(
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_stoppedsms))) Action.STOP_SMS, Sources.SMS, rh.gs(R.string.smscommunicator_stoppedsms),
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_stoppedsms))
)
} }
}) })
} else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) } else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
@ -1074,11 +1166,15 @@ class SmsCommunicatorPlugin @Inject constructor(
if (result) rh.gs(R.string.smscommunicator_calibrationsent) else rh.gs(R.string.smscommunicator_calibrationfailed) if (result) rh.gs(R.string.smscommunicator_calibrationsent) else rh.gs(R.string.smscommunicator_calibrationfailed)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
if (result) if (result)
uel.log(Action.CALIBRATION, Sources.SMS, rh.gs(R.string.smscommunicator_calibrationsent), uel.log(
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_calibrationsent))) Action.CALIBRATION, Sources.SMS, rh.gs(R.string.smscommunicator_calibrationsent),
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_calibrationsent))
)
else else
uel.log(Action.CALIBRATION, Sources.SMS, rh.gs(R.string.smscommunicator_calibrationfailed), uel.log(
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_calibrationfailed))) Action.CALIBRATION, Sources.SMS, rh.gs(R.string.smscommunicator_calibrationfailed),
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.smscommunicator_calibrationfailed))
)
} }
}) })
} else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format))) } else sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
@ -1106,8 +1202,10 @@ class SmsCommunicatorPlugin @Inject constructor(
if (sms.text.toByteArray().size <= 140) smsManager?.sendTextMessage(sms.phoneNumber, null, sms.text, null, null) if (sms.text.toByteArray().size <= 140) smsManager?.sendTextMessage(sms.phoneNumber, null, sms.text, null, null)
else { else {
val parts = smsManager?.divideMessage(sms.text) val parts = smsManager?.divideMessage(sms.text)
smsManager?.sendMultipartTextMessage(sms.phoneNumber, null, parts, smsManager?.sendMultipartTextMessage(
null, null) sms.phoneNumber, null, parts,
null, null
)
} }
messages.add(sms) messages.add(sms)
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {

View file

@ -32,7 +32,7 @@ import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.plugins.databinding.ProfileFragmentBinding import info.nightscout.plugins.databinding.ProfileFragmentBinding
import info.nightscout.plugins.profile.events.EventLocalProfileChanged import info.nightscout.androidaps.events.EventLocalProfileChanged
import info.nightscout.plugins.ui.TimeListEdit import info.nightscout.plugins.ui.TimeListEdit
import info.nightscout.shared.SafeParse import info.nightscout.shared.SafeParse
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger

View file

@ -10,6 +10,7 @@ import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.data.PureProfile import info.nightscout.androidaps.data.PureProfile
import info.nightscout.androidaps.events.EventLocalProfileChanged
import info.nightscout.androidaps.events.EventProfileStoreChanged import info.nightscout.androidaps.events.EventProfileStoreChanged
import info.nightscout.androidaps.extensions.blockFromJsonArray import info.nightscout.androidaps.extensions.blockFromJsonArray
import info.nightscout.androidaps.extensions.pureProfileFromJson import info.nightscout.androidaps.extensions.pureProfileFromJson
@ -35,7 +36,6 @@ import info.nightscout.androidaps.utils.JsonHelper
import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.plugins.profile.events.EventLocalProfileChanged
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
@ -81,39 +81,13 @@ class ProfilePlugin @Inject constructor(
loadSettings() loadSettings()
} }
class SingleProfile {
internal var name: String? = null
internal var mgdl: Boolean = false
var dia: Double = Constants.defaultDIA
var ic: JSONArray? = null
var isf: JSONArray? = null
var basal: JSONArray? = null
internal var targetLow: JSONArray? = null
internal var targetHigh: JSONArray? = null
fun deepClone(): SingleProfile {
val sp = SingleProfile()
sp.name = name
sp.mgdl = mgdl
sp.dia = dia
sp.ic = JSONArray(ic.toString())
sp.isf = JSONArray(isf.toString())
sp.basal = JSONArray(basal.toString())
sp.targetLow = JSONArray(targetLow.toString())
sp.targetHigh = JSONArray(targetHigh.toString())
return sp
}
}
var isEdited: Boolean = false var isEdited: Boolean = false
var profiles: ArrayList<SingleProfile> = ArrayList() var profiles: ArrayList<ProfileSource.SingleProfile> = ArrayList()
val numOfProfiles get() = profiles.size val numOfProfiles get() = profiles.size
var currentProfileIndex = 0 var currentProfileIndex = 0
fun currentProfile(): SingleProfile? = if (numOfProfiles > 0 && currentProfileIndex < numOfProfiles) profiles[currentProfileIndex] else null fun currentProfile(): ProfileSource.SingleProfile? = if (numOfProfiles > 0 && currentProfileIndex < numOfProfiles) profiles[currentProfileIndex] else null
@Synchronized @Synchronized
fun isValidEditState(activity: FragmentActivity?): Boolean { fun isValidEditState(activity: FragmentActivity?): Boolean {
@ -238,7 +212,7 @@ class ProfilePlugin @Inject constructor(
// numOfProfiles = max(numOfProfiles, 1) // create at least one default profile if none exists // numOfProfiles = max(numOfProfiles, 1) // create at least one default profile if none exists
for (i in 0 until numOfProfiles) { for (i in 0 until numOfProfiles) {
val p = SingleProfile() val p = ProfileSource.SingleProfile()
val localProfileNumbered = Constants.LOCAL_PROFILE + "_" + i + "_" val localProfileNumbered = Constants.LOCAL_PROFILE + "_" + i + "_"
p.name = sp.getString(localProfileNumbered + "name", Constants.LOCAL_PROFILE + i) p.name = sp.getString(localProfileNumbered + "name", Constants.LOCAL_PROFILE + i)
@ -263,7 +237,7 @@ class ProfilePlugin @Inject constructor(
@Synchronized @Synchronized
fun loadFromStore(store: ProfileStore) { fun loadFromStore(store: ProfileStore) {
try { try {
val newProfiles: ArrayList<SingleProfile> = ArrayList() val newProfiles: ArrayList<ProfileSource.SingleProfile> = ArrayList()
for (p in store.getProfileList()) { for (p in store.getProfileList()) {
val profile = store.getSpecificProfile(p.toString()) val profile = store.getSpecificProfile(p.toString())
val validityCheck = profile?.let { ProfileSealed.Pure(profile).isValid("NS", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } ?: Profile.ValidityCheck() val validityCheck = profile?.let { ProfileSealed.Pure(profile).isValid("NS", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } ?: Profile.ValidityCheck()
@ -296,14 +270,14 @@ class ProfilePlugin @Inject constructor(
} }
} }
fun copyFrom(pureProfile: PureProfile, newName: String): SingleProfile { override fun copyFrom(pureProfile: PureProfile, newName: String): ProfileSource.SingleProfile {
var verifiedName = newName var verifiedName = newName
if (rawProfile?.getSpecificProfile(newName) != null) { if (rawProfile?.getSpecificProfile(newName) != null) {
verifiedName += " " + dateUtil.now().toString() verifiedName += " " + dateUtil.now().toString()
} }
val profile = ProfileSealed.Pure(pureProfile) val profile = ProfileSealed.Pure(pureProfile)
val pureJson = pureProfile.jsonObject val pureJson = pureProfile.jsonObject
val sp = SingleProfile() val sp = ProfileSource.SingleProfile()
sp.name = verifiedName sp.name = verifiedName
sp.mgdl = profile.units == GlucoseUnit.MGDL sp.mgdl = profile.units == GlucoseUnit.MGDL
sp.dia = pureJson.getDouble("dia") sp.dia = pureJson.getDouble("dia")
@ -372,7 +346,7 @@ class ProfilePlugin @Inject constructor(
break break
} }
} }
val p = SingleProfile() val p = ProfileSource.SingleProfile()
p.name = Constants.LOCAL_PROFILE + free p.name = Constants.LOCAL_PROFILE + free
p.mgdl = profileFunction.getUnits() == GlucoseUnit.MGDL p.mgdl = profileFunction.getUnits() == GlucoseUnit.MGDL
p.dia = Constants.defaultDIA p.dia = Constants.defaultDIA
@ -397,7 +371,7 @@ class ProfilePlugin @Inject constructor(
isEdited = false isEdited = false
} }
fun addProfile(p: SingleProfile) { override fun addProfile(p: ProfileSource.SingleProfile) {
profiles.add(p) profiles.add(p)
currentProfileIndex = profiles.size - 1 currentProfileIndex = profiles.size - 1
createAndStoreConvertedProfile() createAndStoreConvertedProfile()

View file

@ -1,5 +0,0 @@
package info.nightscout.plugins.profile.events
import info.nightscout.androidaps.events.Event
class EventLocalProfileChanged : Event()

View file

@ -199,7 +199,6 @@
<string name="ic_short">IC</string> <string name="ic_short">IC</string>
<string name="isf_short">ISF</string> <string name="isf_short">ISF</string>
<string name="target_short">TARG</string> <string name="target_short">TARG</string>
<string name="clone_label">Clone</string>
<string name="basal_short">BAS</string> <string name="basal_short">BAS</string>
<!-- BG Quality --> <!-- BG Quality -->

View file

@ -13,8 +13,9 @@ android {
} }
dependencies { dependencies {
implementation project(':libraries')
implementation project(':graphview')
implementation project(':shared') implementation project(':shared')
implementation project(':database') implementation project(':database')
implementation project(':core') implementation project(':core')
implementation project(':graphview')
} }

View file

@ -43,6 +43,10 @@
android:name=".activities.StatsActivity" android:name=".activities.StatsActivity"
android:exported="false" android:exported="false"
android:theme="@style/AppTheme" /> android:theme="@style/AppTheme" />
<activity
android:name="info.nightscout.ui.activities.TreatmentsActivity"
android:exported="false"
android:theme="@style/AppTheme" />
</application> </application>

View file

@ -1,23 +1,23 @@
package info.nightscout.androidaps.activities package info.nightscout.ui.activities
import android.os.Bundle import android.os.Bundle
import android.view.MenuItem import android.view.MenuItem
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction import androidx.fragment.app.FragmentTransaction
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.fragments.TreatmentsBolusCarbsFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsCareportalFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsExtendedBolusesFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsProfileSwitchFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsTempTargetFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsTemporaryBasalsFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsUserEntryFragment
import info.nightscout.androidaps.databinding.TreatmentsFragmentBinding
import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.BuildHelper import info.nightscout.androidaps.interfaces.BuildHelper
import info.nightscout.ui.R
import info.nightscout.ui.activities.fragments.TreatmentsBolusCarbsFragment
import info.nightscout.ui.activities.fragments.TreatmentsCareportalFragment
import info.nightscout.ui.activities.fragments.TreatmentsExtendedBolusesFragment
import info.nightscout.ui.activities.fragments.TreatmentsProfileSwitchFragment
import info.nightscout.ui.activities.fragments.TreatmentsTempTargetFragment
import info.nightscout.ui.activities.fragments.TreatmentsTemporaryBasalsFragment
import info.nightscout.ui.activities.fragments.TreatmentsUserEntryFragment
import info.nightscout.ui.databinding.TreatmentsFragmentBinding
import javax.inject.Inject import javax.inject.Inject
class TreatmentsActivity : NoSplashAppCompatActivity() { class TreatmentsActivity : NoSplashAppCompatActivity() {
@ -41,7 +41,7 @@ class TreatmentsActivity : NoSplashAppCompatActivity() {
supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.title = rh.gs(R.string.carbs_and_bolus) supportActionBar?.title = rh.gs(R.string.carbs_and_bolus)
binding.treatmentsTabs.addOnTabSelectedListener(object : OnTabSelectedListener { binding.treatmentsTabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab) { override fun onTabSelected(tab: TabLayout.Tab) {
val fragment = when (tab.position) { val fragment = when (tab.position) {
0 -> TreatmentsBolusCarbsFragment::class.java 0 -> TreatmentsBolusCarbsFragment::class.java
@ -78,4 +78,4 @@ class TreatmentsActivity : NoSplashAppCompatActivity() {
.commit() .commit()
} }
} }

View file

@ -1,17 +1,21 @@
package info.nightscout.androidaps.activities.fragments package info.nightscout.ui.activities.fragments
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.graphics.Paint import android.graphics.Paint
import android.os.Bundle import android.os.Bundle
import android.util.SparseArray import android.util.SparseArray
import android.view.* import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.core.util.forEach import androidx.core.util.forEach
import androidx.core.view.MenuProvider import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.Bolus import info.nightscout.androidaps.database.entities.Bolus
import info.nightscout.androidaps.database.entities.BolusCalculatorResult import info.nightscout.androidaps.database.entities.BolusCalculatorResult
@ -23,9 +27,8 @@ import info.nightscout.androidaps.database.transactions.CutCarbsTransaction
import info.nightscout.androidaps.database.transactions.InvalidateBolusCalculatorResultTransaction import info.nightscout.androidaps.database.transactions.InvalidateBolusCalculatorResultTransaction
import info.nightscout.androidaps.database.transactions.InvalidateBolusTransaction import info.nightscout.androidaps.database.transactions.InvalidateBolusTransaction
import info.nightscout.androidaps.database.transactions.InvalidateCarbsTransaction import info.nightscout.androidaps.database.transactions.InvalidateCarbsTransaction
import info.nightscout.androidaps.databinding.TreatmentsBolusCarbsFragmentBinding import info.nightscout.androidaps.events.EventNSClientRestart
import info.nightscout.androidaps.databinding.TreatmentsBolusCarbsItemBinding import info.nightscout.androidaps.events.EventNewHistoryData
import info.nightscout.androidaps.dialogs.WizardInfoDialog
import info.nightscout.androidaps.events.EventTreatmentChange import info.nightscout.androidaps.events.EventTreatmentChange
import info.nightscout.androidaps.extensions.iobCalc import info.nightscout.androidaps.extensions.iobCalc
import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.extensions.toVisibility
@ -35,8 +38,6 @@ import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.plugins.general.nsclient.events.EventNSClientRestart
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData
import info.nightscout.androidaps.utils.ActionModeHelper import info.nightscout.androidaps.utils.ActionModeHelper
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
@ -47,6 +48,10 @@ import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.ui.R
import info.nightscout.ui.databinding.TreatmentsBolusCarbsFragmentBinding
import info.nightscout.ui.databinding.TreatmentsBolusCarbsItemBinding
import info.nightscout.ui.dialogs.WizardInfoDialog
import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
@ -126,7 +131,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment(), MenuProvider {
.getBolusCalculatorResultsDataFromTime(now - millsToThePast, false) .getBolusCalculatorResultsDataFromTime(now - millsToThePast, false)
.map { calc -> calc.map { MealLink(bolusCalculatorResult = it) } } .map { calc -> calc.map { MealLink(bolusCalculatorResult = it) } }
fun swapAdapter() { private fun swapAdapter() {
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
binding.recyclerview.isLoading = true binding.recyclerview.isLoading = true
disposable += disposable +=
@ -232,7 +237,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment(), MenuProvider {
holder.binding.mealOrCorrection.text = holder.binding.mealOrCorrection.text =
when (ml.bolus.type) { when (ml.bolus.type) {
Bolus.Type.SMB -> "SMB" Bolus.Type.SMB -> "SMB"
Bolus.Type.NORMAL -> rh.gs(R.string.mealbolus) Bolus.Type.NORMAL -> rh.gs(R.string.meal_bolus)
Bolus.Type.PRIMING -> rh.gs(R.string.prime) Bolus.Type.PRIMING -> rh.gs(R.string.prime)
} }
holder.binding.cbBolusRemove.visibility = (ml.bolus.isValid && actionHelper.isRemoving).toVisibility() holder.binding.cbBolusRemove.visibility = (ml.bolus.isValid && actionHelper.isRemoving).toVisibility()
@ -371,7 +376,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment(), MenuProvider {
private fun deleteFutureTreatments() { private fun deleteFutureTreatments() {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, rh.gs(R.string.overview_treatment_label), rh.gs(R.string.deletefuturetreatments) + "?", Runnable { OKDialog.showConfirmation(activity, rh.gs(R.string.overview_treatment_label), rh.gs(R.string.delete_future_treatments) + "?", Runnable {
uel.log(Action.DELETE_FUTURE_TREATMENTS, Sources.Treatments) uel.log(Action.DELETE_FUTURE_TREATMENTS, Sources.Treatments)
disposable += repository disposable += repository
.getBolusesDataFromTime(dateUtil.now(), false) .getBolusesDataFromTime(dateUtil.now(), false)

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.activities.fragments package info.nightscout.ui.activities.fragments
import android.os.Bundle import android.os.Bundle
import android.util.SparseArray import android.util.SparseArray
@ -9,8 +9,7 @@ import androidx.lifecycle.Lifecycle
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.ui.activities.fragments.TreatmentsCareportalFragment.RecyclerViewAdapter.TherapyEventsViewHolder
import info.nightscout.androidaps.activities.fragments.TreatmentsCareportalFragment.RecyclerViewAdapter.TherapyEventsViewHolder
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.TherapyEvent import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Action
@ -18,21 +17,22 @@ import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.database.entities.ValueWithUnit import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.transactions.InvalidateAAPSStartedTherapyEventTransaction import info.nightscout.androidaps.database.transactions.InvalidateAAPSStartedTherapyEventTransaction
import info.nightscout.androidaps.database.transactions.InvalidateTherapyEventTransaction import info.nightscout.androidaps.database.transactions.InvalidateTherapyEventTransaction
import info.nightscout.androidaps.databinding.TreatmentsCareportalFragmentBinding import info.nightscout.androidaps.events.EventNSClientRestart
import info.nightscout.androidaps.databinding.TreatmentsCareportalItemBinding
import info.nightscout.androidaps.events.EventTherapyEventChange import info.nightscout.androidaps.events.EventTherapyEventChange
import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.BuildHelper import info.nightscout.androidaps.interfaces.BuildHelper
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.plugins.general.nsclient.events.EventNSClientRestart
import info.nightscout.androidaps.utils.* import info.nightscout.androidaps.utils.*
import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.ui.R
import info.nightscout.ui.databinding.TreatmentsCareportalFragmentBinding
import info.nightscout.ui.databinding.TreatmentsCareportalItemBinding
import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
@ -96,7 +96,7 @@ class TreatmentsCareportalFragment : DaggerFragment(), MenuProvider {
private fun removeStartedEvents() { private fun removeStartedEvents() {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, rh.gs(R.string.careportal), rh.gs(R.string.careportal_removestartedevents), Runnable { OKDialog.showConfirmation(activity, rh.gs(R.string.careportal), rh.gs(R.string.careportal_remove_started_events), Runnable {
uel.log(Action.RESTART_EVENTS_REMOVED, Sources.Treatments) uel.log(Action.RESTART_EVENTS_REMOVED, Sources.Treatments)
disposable += repository.runTransactionForResult(InvalidateAAPSStartedTherapyEventTransaction(rh.gs(R.string.androidaps_start))) disposable += repository.runTransactionForResult(InvalidateAAPSStartedTherapyEventTransaction(rh.gs(R.string.androidaps_start)))
.subscribe( .subscribe(

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.activities.fragments package info.nightscout.ui.activities.fragments
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
@ -10,8 +10,7 @@ import androidx.lifecycle.Lifecycle
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.ui.activities.fragments.TreatmentsExtendedBolusesFragment.RecyclerViewAdapter.ExtendedBolusesViewHolder
import info.nightscout.androidaps.activities.fragments.TreatmentsExtendedBolusesFragment.RecyclerViewAdapter.ExtendedBolusesViewHolder
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.ExtendedBolus import info.nightscout.androidaps.database.entities.ExtendedBolus
import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Action
@ -19,8 +18,6 @@ import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.database.entities.ValueWithUnit import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.interfaces.end import info.nightscout.androidaps.database.interfaces.end
import info.nightscout.androidaps.database.transactions.InvalidateExtendedBolusTransaction import info.nightscout.androidaps.database.transactions.InvalidateExtendedBolusTransaction
import info.nightscout.androidaps.databinding.TreatmentsExtendedbolusFragmentBinding
import info.nightscout.androidaps.databinding.TreatmentsExtendedbolusItemBinding
import info.nightscout.androidaps.events.EventExtendedBolusChange import info.nightscout.androidaps.events.EventExtendedBolusChange
import info.nightscout.androidaps.extensions.iobCalc import info.nightscout.androidaps.extensions.iobCalc
import info.nightscout.androidaps.extensions.isInProgress import info.nightscout.androidaps.extensions.isInProgress
@ -39,6 +36,9 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.ui.R
import info.nightscout.ui.databinding.TreatmentsExtendedbolusFragmentBinding
import info.nightscout.ui.databinding.TreatmentsExtendedbolusItemBinding
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -85,7 +85,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment(), MenuProvider {
requireActivity().addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.RESUMED) requireActivity().addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.RESUMED)
} }
fun swapAdapter() { private fun swapAdapter() {
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
binding.recyclerview.isLoading = true binding.recyclerview.isLoading = true
disposable += if (showInvalidated) disposable += if (showInvalidated)

View file

@ -1,49 +1,54 @@
package info.nightscout.androidaps.activities.fragments package info.nightscout.ui.activities.fragments
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.graphics.Paint import android.graphics.Paint
import android.os.Bundle import android.os.Bundle
import android.util.SparseArray import android.util.SparseArray
import android.view.* import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.core.util.forEach import androidx.core.util.forEach
import androidx.core.view.MenuProvider import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.fragments.TreatmentsProfileSwitchFragment.RecyclerProfileViewAdapter.ProfileSwitchViewHolder
import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.database.entities.ValueWithUnit import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.transactions.InvalidateProfileSwitchTransaction import info.nightscout.androidaps.database.transactions.InvalidateProfileSwitchTransaction
import info.nightscout.androidaps.databinding.TreatmentsProfileswitchFragmentBinding
import info.nightscout.androidaps.databinding.TreatmentsProfileswitchItemBinding
import info.nightscout.androidaps.dialogs.ProfileViewerDialog import info.nightscout.androidaps.dialogs.ProfileViewerDialog
import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged
import info.nightscout.androidaps.events.EventLocalProfileChanged
import info.nightscout.androidaps.events.EventNSClientRestart
import info.nightscout.androidaps.events.EventNewHistoryData
import info.nightscout.androidaps.events.EventProfileSwitchChanged import info.nightscout.androidaps.events.EventProfileSwitchChanged
import info.nightscout.androidaps.extensions.getCustomizedName import info.nightscout.androidaps.extensions.getCustomizedName
import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.BuildHelper
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.plugins.general.nsclient.events.EventNSClientRestart
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData
import info.nightscout.plugins.profile.ProfilePlugin
import info.nightscout.plugins.profile.events.EventLocalProfileChanged
import info.nightscout.androidaps.utils.ActionModeHelper import info.nightscout.androidaps.utils.ActionModeHelper
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.interfaces.BuildHelper
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.ui.R
import info.nightscout.ui.activities.fragments.TreatmentsProfileSwitchFragment.RecyclerProfileViewAdapter.ProfileSwitchViewHolder
import info.nightscout.ui.databinding.TreatmentsProfileswitchFragmentBinding
import info.nightscout.ui.databinding.TreatmentsProfileswitchItemBinding
import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
@ -55,7 +60,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment(), MenuProvider {
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
@Inject lateinit var sp: SP @Inject lateinit var sp: SP
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var profilePlugin: ProfilePlugin @Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var rh: ResourceHelper @Inject lateinit var rh: ResourceHelper
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var dateUtil: DateUtil @Inject lateinit var dateUtil: DateUtil
@ -130,7 +135,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment(), MenuProvider {
.getEffectiveProfileSwitchDataFromTime(now - millsToThePast, false) .getEffectiveProfileSwitchDataFromTime(now - millsToThePast, false)
.map { carb -> carb.map { ProfileSealed.EPS(it) } } .map { carb -> carb.map { ProfileSealed.EPS(it) } }
fun swapAdapter() { private fun swapAdapter() {
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
binding.recyclerview.isLoading = true binding.recyclerview.isLoading = true
disposable += disposable +=
@ -196,7 +201,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment(), MenuProvider {
holder.binding.duration.text = rh.gs(R.string.format_mins, T.msecs(profileSwitch.duration ?: 0L).mins()) holder.binding.duration.text = rh.gs(R.string.format_mins, T.msecs(profileSwitch.duration ?: 0L).mins())
holder.binding.name.text = holder.binding.name.text =
if (profileSwitch is ProfileSealed.PS) profileSwitch.value.getCustomizedName() else if (profileSwitch is ProfileSealed.EPS) profileSwitch.value.originalCustomizedName else "" if (profileSwitch is ProfileSealed.PS) profileSwitch.value.getCustomizedName() else if (profileSwitch is ProfileSealed.EPS) profileSwitch.value.originalCustomizedName else ""
if (profileSwitch.isInProgress(dateUtil)) holder.binding.date.setTextColor(rh.gac(context , R.attr.activeColor)) if (profileSwitch.isInProgress(dateUtil)) holder.binding.date.setTextColor(rh.gac(context, R.attr.activeColor))
else holder.binding.date.setTextColor(holder.binding.duration.currentTextColor) else holder.binding.date.setTextColor(holder.binding.duration.currentTextColor)
holder.binding.clone.tag = profileSwitch holder.binding.clone.tag = profileSwitch
holder.binding.name.tag = profileSwitch holder.binding.name.tag = profileSwitch
@ -241,8 +246,8 @@ class TreatmentsProfileSwitchFragment : DaggerFragment(), MenuProvider {
ValueWithUnit.SimpleString(profileSwitch.profileName) ValueWithUnit.SimpleString(profileSwitch.profileName)
) )
val nonCustomized = profileSealed.convertToNonCustomizedProfile(dateUtil) val nonCustomized = profileSealed.convertToNonCustomizedProfile(dateUtil)
profilePlugin.addProfile( activePlugin.activeProfileSource.addProfile(
profilePlugin.copyFrom( activePlugin.activeProfileSource.copyFrom(
nonCustomized, nonCustomized,
profileSwitch.getCustomizedName() + " " + dateUtil.dateAndTimeString(profileSwitch.timestamp).replace(".", "_") profileSwitch.getCustomizedName() + " " + dateUtil.dateAndTimeString(profileSwitch.timestamp).replace(".", "_")
) )

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.activities.fragments package info.nightscout.ui.activities.fragments
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
@ -10,8 +10,7 @@ import androidx.lifecycle.Lifecycle
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.ui.activities.fragments.TreatmentsTempTargetFragment.RecyclerViewAdapter.TempTargetsViewHolder
import info.nightscout.androidaps.activities.fragments.TreatmentsTempTargetFragment.RecyclerViewAdapter.TempTargetsViewHolder
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.ValueWrapper import info.nightscout.androidaps.database.ValueWrapper
import info.nightscout.androidaps.database.entities.TemporaryTarget import info.nightscout.androidaps.database.entities.TemporaryTarget
@ -20,9 +19,9 @@ import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.database.entities.ValueWithUnit import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.interfaces.end import info.nightscout.androidaps.database.interfaces.end
import info.nightscout.androidaps.database.transactions.InvalidateTemporaryTargetTransaction import info.nightscout.androidaps.database.transactions.InvalidateTemporaryTargetTransaction
import info.nightscout.androidaps.databinding.TreatmentsTemptargetFragmentBinding
import info.nightscout.androidaps.databinding.TreatmentsTemptargetItemBinding
import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged
import info.nightscout.androidaps.events.EventNSClientRestart
import info.nightscout.androidaps.events.EventNewHistoryData
import info.nightscout.androidaps.events.EventProfileSwitchChanged import info.nightscout.androidaps.events.EventProfileSwitchChanged
import info.nightscout.androidaps.events.EventTempTargetChange import info.nightscout.androidaps.events.EventTempTargetChange
import info.nightscout.androidaps.extensions.friendlyDescription import info.nightscout.androidaps.extensions.friendlyDescription
@ -34,14 +33,15 @@ import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.plugins.general.nsclient.events.EventNSClientRestart
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData
import info.nightscout.androidaps.utils.* import info.nightscout.androidaps.utils.*
import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.ui.R
import info.nightscout.ui.databinding.TreatmentsTemptargetFragmentBinding
import info.nightscout.ui.databinding.TreatmentsTemptargetItemBinding
import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
@ -113,7 +113,7 @@ class TreatmentsTempTargetFragment : DaggerFragment(), MenuProvider {
} }
} }
fun swapAdapter() { private fun swapAdapter() {
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
binding.recyclerview.isLoading = true binding.recyclerview.isLoading = true
disposable += disposable +=

View file

@ -1,17 +1,20 @@
package info.nightscout.androidaps.activities.fragments package info.nightscout.ui.activities.fragments
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import android.util.SparseArray import android.util.SparseArray
import android.view.* import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.core.util.forEach import androidx.core.util.forEach
import androidx.core.view.MenuProvider import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.fragments.TreatmentsTemporaryBasalsFragment.RecyclerViewAdapter.TempBasalsViewHolder
import info.nightscout.androidaps.data.IobTotal import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.ValueWrapper import info.nightscout.androidaps.database.ValueWrapper
@ -23,8 +26,6 @@ import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.interfaces.end import info.nightscout.androidaps.database.interfaces.end
import info.nightscout.androidaps.database.transactions.InvalidateExtendedBolusTransaction import info.nightscout.androidaps.database.transactions.InvalidateExtendedBolusTransaction
import info.nightscout.androidaps.database.transactions.InvalidateTemporaryBasalTransaction import info.nightscout.androidaps.database.transactions.InvalidateTemporaryBasalTransaction
import info.nightscout.androidaps.databinding.TreatmentsTempbasalsFragmentBinding
import info.nightscout.androidaps.databinding.TreatmentsTempbasalsItemBinding
import info.nightscout.androidaps.events.EventTempBasalChange import info.nightscout.androidaps.events.EventTempBasalChange
import info.nightscout.androidaps.extensions.iobCalc import info.nightscout.androidaps.extensions.iobCalc
import info.nightscout.androidaps.extensions.toStringFull import info.nightscout.androidaps.extensions.toStringFull
@ -44,6 +45,10 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.ui.R
import info.nightscout.ui.activities.fragments.TreatmentsTemporaryBasalsFragment.RecyclerViewAdapter.TempBasalsViewHolder
import info.nightscout.ui.databinding.TreatmentsTempbasalsFragmentBinding
import info.nightscout.ui.databinding.TreatmentsTempbasalsItemBinding
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -104,7 +109,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment(), MenuProvider {
.getExtendedBolusDataFromTime(now - millsToThePast, false) .getExtendedBolusDataFromTime(now - millsToThePast, false)
.map { eb -> eb.map { profileFunction.getProfile(it.timestamp)?.let { profile -> it.toTemporaryBasal(profile) } } } .map { eb -> eb.map { profileFunction.getProfile(it.timestamp)?.let { profile -> it.toTemporaryBasal(profile) } } }
fun swapAdapter() { private fun swapAdapter() {
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
binding.recyclerview.isLoading = true binding.recyclerview.isLoading = true
disposable += disposable +=

View file

@ -1,19 +1,21 @@
package info.nightscout.androidaps.activities.fragments package info.nightscout.ui.activities.fragments
import android.os.Bundle import android.os.Bundle
import android.view.* import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.core.view.MenuProvider import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.databinding.TreatmentsUserEntryFragmentBinding
import info.nightscout.androidaps.databinding.TreatmentsUserEntryItemBinding
import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.ImportExportPrefs import info.nightscout.androidaps.interfaces.ImportExportPrefs
@ -25,10 +27,12 @@ import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.Translator
import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.androidaps.utils.userEntry.UserEntryPresentationHelper import info.nightscout.androidaps.utils.userEntry.UserEntryPresentationHelper
import info.nightscout.ui.R
import info.nightscout.ui.databinding.TreatmentsUserEntryFragmentBinding
import info.nightscout.ui.databinding.TreatmentsUserEntryItemBinding
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import javax.inject.Inject import javax.inject.Inject
@ -42,7 +46,6 @@ class TreatmentsUserEntryFragment : DaggerFragment(), MenuProvider {
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
@Inject lateinit var translator: Translator
@Inject lateinit var importExportPrefs: ImportExportPrefs @Inject lateinit var importExportPrefs: ImportExportPrefs
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger
@Inject lateinit var userEntryPresentationHelper: UserEntryPresentationHelper @Inject lateinit var userEntryPresentationHelper: UserEntryPresentationHelper
@ -78,7 +81,7 @@ class TreatmentsUserEntryFragment : DaggerFragment(), MenuProvider {
} }
} }
fun swapAdapter() { private fun swapAdapter() {
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
binding.recyclerview.isLoading = true binding.recyclerview.isLoading = true
disposable += disposable +=

View file

@ -7,9 +7,18 @@ import info.nightscout.ui.activities.ErrorHelperActivity
import info.nightscout.ui.activities.StatsActivity import info.nightscout.ui.activities.StatsActivity
import info.nightscout.ui.activities.SurveyActivity import info.nightscout.ui.activities.SurveyActivity
import info.nightscout.ui.activities.TDDStatsActivity import info.nightscout.ui.activities.TDDStatsActivity
import info.nightscout.ui.activities.TreatmentsActivity
import info.nightscout.ui.activities.fragments.TreatmentsBolusCarbsFragment
import info.nightscout.ui.activities.fragments.TreatmentsCareportalFragment
import info.nightscout.ui.activities.fragments.TreatmentsExtendedBolusesFragment
import info.nightscout.ui.activities.fragments.TreatmentsProfileSwitchFragment
import info.nightscout.ui.activities.fragments.TreatmentsTempTargetFragment
import info.nightscout.ui.activities.fragments.TreatmentsTemporaryBasalsFragment
import info.nightscout.ui.activities.fragments.TreatmentsUserEntryFragment
import info.nightscout.ui.dialogs.CalibrationDialog import info.nightscout.ui.dialogs.CalibrationDialog
import info.nightscout.ui.dialogs.CarbsDialog import info.nightscout.ui.dialogs.CarbsDialog
import info.nightscout.ui.dialogs.CareDialog import info.nightscout.ui.dialogs.CareDialog
import info.nightscout.ui.dialogs.WizardInfoDialog
@Module @Module
@Suppress("unused") @Suppress("unused")
@ -18,11 +27,21 @@ abstract class UiModule {
@ContributesAndroidInjector abstract fun contributesCalibrationDialog(): CalibrationDialog @ContributesAndroidInjector abstract fun contributesCalibrationDialog(): CalibrationDialog
@ContributesAndroidInjector abstract fun contributesCarbsDialog(): CarbsDialog @ContributesAndroidInjector abstract fun contributesCarbsDialog(): CarbsDialog
@ContributesAndroidInjector abstract fun contributesCareDialog(): CareDialog @ContributesAndroidInjector abstract fun contributesCareDialog(): CareDialog
@ContributesAndroidInjector abstract fun contributesWizardInfoDialog(): WizardInfoDialog
@ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity @ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity
@ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity @ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity
@ContributesAndroidInjector abstract fun contributeErrorHelperActivity(): ErrorHelperActivity @ContributesAndroidInjector abstract fun contributeErrorHelperActivity(): ErrorHelperActivity
@ContributesAndroidInjector abstract fun contributesStatsActivity(): StatsActivity @ContributesAndroidInjector abstract fun contributesStatsActivity(): StatsActivity
@ContributesAndroidInjector abstract fun contributesSurveyActivity(): SurveyActivity @ContributesAndroidInjector abstract fun contributesSurveyActivity(): SurveyActivity
@ContributesAndroidInjector abstract fun contributesTreatmentsActivity(): TreatmentsActivity
@ContributesAndroidInjector abstract fun contributesTreatmentsBolusFragment(): TreatmentsBolusCarbsFragment
@ContributesAndroidInjector abstract fun contributesTreatmentsTemporaryBasalsFragment(): TreatmentsTemporaryBasalsFragment
@ContributesAndroidInjector abstract fun contributesTreatmentsTempTargetFragment(): TreatmentsTempTargetFragment
@ContributesAndroidInjector abstract fun contributesTreatmentsExtendedBolusesFragment(): TreatmentsExtendedBolusesFragment
@ContributesAndroidInjector abstract fun contributesTreatmentsCareportalFragment(): TreatmentsCareportalFragment
@ContributesAndroidInjector abstract fun contributesTreatmentsProfileSwitchFragment(): TreatmentsProfileSwitchFragment
@ContributesAndroidInjector abstract fun contributesTreatmentsUserEntryFragment(): TreatmentsUserEntryFragment
} }

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.dialogs package info.nightscout.ui.dialogs
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -8,16 +8,15 @@ import android.view.Window
import android.view.WindowManager import android.view.WindowManager
import dagger.android.support.DaggerDialogFragment import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.BolusCalculatorResult import info.nightscout.androidaps.database.entities.BolusCalculatorResult
import info.nightscout.androidaps.databinding.DialogWizardinfoBinding
import info.nightscout.androidaps.extensions.bolusCalculatorResultFromJson import info.nightscout.androidaps.extensions.bolusCalculatorResultFromJson
import info.nightscout.androidaps.extensions.toJson import info.nightscout.androidaps.extensions.toJson
import info.nightscout.androidaps.interfaces.Profile import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.ui.R
import info.nightscout.ui.databinding.DialogWizardinfoBinding
import org.json.JSONObject import org.json.JSONObject
import javax.inject.Inject import javax.inject.Inject
@ -91,13 +90,13 @@ class WizardInfoDialog : DaggerDialogFragment() {
binding.basalIobInsulin.text = rh.gs(R.string.formatinsulinunits, data.basalIOB) binding.basalIobInsulin.text = rh.gs(R.string.formatinsulinunits, data.basalIOB)
binding.basalIobCheckbox.isChecked = data.wasBasalIOBUsed binding.basalIobCheckbox.isChecked = data.wasBasalIOBUsed
// Superbolus // Superbolus
binding.sbinsulin.text = rh.gs(R.string.formatinsulinunits, data.superbolusInsulin) binding.sbInsulin.text = rh.gs(R.string.formatinsulinunits, data.superbolusInsulin)
binding.sbCheckbox.isChecked = data.wasSuperbolusUsed binding.sbCheckbox.isChecked = data.wasSuperbolusUsed
// Carbs // Carbs
binding.carbs.text = rh.gs(R.string.format_carbs_ic, data.carbs, data.ic) binding.carbs.text = rh.gs(R.string.format_carbs_ic, data.carbs, data.ic)
binding.carbsinsulin.text = rh.gs(R.string.formatinsulinunits, data.carbsInsulin) binding.carbsInsulin.text = rh.gs(R.string.formatinsulinunits, data.carbsInsulin)
// Correction // Correction
binding.correctioninsulin.text = rh.gs(R.string.formatinsulinunits, data.otherCorrection) binding.correctionInsulin.text = rh.gs(R.string.formatinsulinunits, data.otherCorrection)
// Profile // Profile
binding.profile.text = data.profileName binding.profile.text = data.profileName
// Notes // Notes
@ -105,7 +104,7 @@ class WizardInfoDialog : DaggerDialogFragment() {
// Percentage // Percentage
binding.percentUsed.text = rh.gs(R.string.format_percent, data.percentageCorrection) binding.percentUsed.text = rh.gs(R.string.format_percent, data.percentageCorrection)
// Total // Total
binding.totalinsulin.text = rh.gs(R.string.formatinsulinunits, data.totalInsulin) binding.totalInsulin.text = rh.gs(R.string.formatinsulinunits, data.totalInsulin)
} }
override fun onStart() { override fun onStart() {
@ -117,4 +116,4 @@ class WizardInfoDialog : DaggerDialogFragment() {
super.onDestroyView() super.onDestroyView()
_binding = null _binding = null
} }
} }

View file

@ -265,7 +265,7 @@
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView <TextView
android:id="@+id/sbinsulin" android:id="@+id/sb_insulin"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:width="50dp" android:width="50dp"
@ -299,7 +299,7 @@
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView <TextView
android:id="@+id/carbsinsulin" android:id="@+id/carbs_insulin"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:width="50dp" android:width="50dp"
@ -332,7 +332,7 @@
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView <TextView
android:id="@+id/correctioninsulin" android:id="@+id/correction_insulin"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:width="50dp" android:width="50dp"
@ -467,7 +467,7 @@
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView <TextView
android:id="@+id/totalinsulin" android:id="@+id/total_insulin"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:width="50dp" android:width="50dp"

View file

@ -3,7 +3,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context="info.nightscout.androidaps.activities.fragments.TreatmentsBolusCarbsFragment"> tools:context=".activities.fragments.TreatmentsBolusCarbsFragment">
<ProgressBar <ProgressBar
android:id="@+id/progress_bar" android:id="@+id/progress_bar"

View file

@ -3,7 +3,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context="info.nightscout.androidaps.activities.fragments.TreatmentsCareportalFragment"> tools:context="activities.fragments.TreatmentsCareportalFragment">
<ProgressBar <ProgressBar
android:id="@+id/progress_bar" android:id="@+id/progress_bar"

View file

@ -3,7 +3,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context="info.nightscout.androidaps.activities.fragments.TreatmentsExtendedBolusesFragment"> tools:context=".activities.fragments.TreatmentsExtendedBolusesFragment">
<ProgressBar <ProgressBar
android:id="@+id/progress_bar" android:id="@+id/progress_bar"

View file

@ -3,7 +3,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context="info.nightscout.androidaps.activities.TreatmentsActivity"> tools:context=".activities.TreatmentsActivity">
<com.google.android.material.appbar.MaterialToolbar <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
@ -55,7 +55,7 @@
<com.google.android.material.tabs.TabItem <com.google.android.material.tabs.TabItem
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@string/userentry" android:contentDescription="@string/user_entry"
android:icon="@drawable/ic_danar_useropt" /> android:icon="@drawable/ic_danar_useropt" />
</com.google.android.material.tabs.TabLayout> </com.google.android.material.tabs.TabLayout>

View file

@ -3,7 +3,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context="info.nightscout.androidaps.activities.fragments.TreatmentsProfileSwitchFragment"> tools:context=".activities.fragments.TreatmentsProfileSwitchFragment">
<ProgressBar <ProgressBar
android:id="@+id/progress_bar" android:id="@+id/progress_bar"

View file

@ -3,7 +3,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context="info.nightscout.androidaps.activities.fragments.TreatmentsTemporaryBasalsFragment"> tools:context=".activities.fragments.TreatmentsTemporaryBasalsFragment">
<ProgressBar <ProgressBar
android:id="@+id/progress_bar" android:id="@+id/progress_bar"

View file

@ -3,7 +3,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context="info.nightscout.androidaps.activities.fragments.TreatmentsTempTargetFragment"> tools:context=".activities.fragments.TreatmentsTempTargetFragment">
<ProgressBar <ProgressBar
android:id="@+id/progress_bar" android:id="@+id/progress_bar"

View file

@ -3,7 +3,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context="info.nightscout.androidaps.activities.fragments.TreatmentsUserEntryFragment"> tools:context=".activities.fragments.TreatmentsUserEntryFragment">
<ProgressBar <ProgressBar
android:id="@+id/progress_bar" android:id="@+id/progress_bar"

View file

@ -26,7 +26,7 @@
<item <item
android:id="@+id/nav_remove_started_events" android:id="@+id/nav_remove_started_events"
android:title="@string/careportal_removestartedevents" android:title="@string/careportal_remove_started_events"
app:showAsAction="never" /> app:showAsAction="never" />
</menu> </menu>

View file

@ -39,4 +39,47 @@
<string name="bg_meter">Meter</string> <string name="bg_meter">Meter</string>
<string name="bg_sensor">Sensor</string> <string name="bg_sensor">Sensor</string>
<!-- WizardDialog -->
<string name="format_bg_isf">%1$s ISF: %2$.1f</string>
<string name="format_cob_ic">%1$.1fg IC: %2$.1f</string>
<string name="format_carbs_ic">%1$.0fg IC: %2$.1f</string>
<string name="format_percent">%1$d%%</string>
<string name="superbolus">Superbolus</string>
<string name="treatments_wizard_total_label">Total</string>
<!-- Treatments -->
<string name="no_records_available">No records available</string>
<string name="calculation_short">Calc</string>
<string name="treatments_iob_label_string">IOB:</string>
<string name="invalid">INVALID</string>
<string name="treatments_insulin_label_string">Insulin:</string>
<string name="treatments_carbs_label_string">Carbs:</string>
<string name="treatments_iobtotal_label_string">Total IOB:</string>
<string name="treatments_iob_activity_total_label_string">Total IOB activity:</string>
<string name="tempbasals_realduration_label_string">Dur:</string>
<string name="tempbasals_netratio_label_string">Ratio:</string>
<string name="tempbasals_netinsulin_label_string">Ins:</string>
<string name="tempbasals_iob_label_string">IOB:</string>
<string name="tempbasals_iobtotal_label_string">Total IOB:</string>
<string name="treatments_wizard_tt_label">TT</string>
<string name="treatments_wizard_correction_label">Corr</string>
<string name="meal_bolus">Meal</string>
<string name="prime">Prime</string>
<string name="profile_changes">Profile changes</string>
<string name="tempt_targets">Temp Targets</string>
<string name="carbs_and_bolus">Carbs and bolus</string>
<string name="show_invalidated_records">Show invalidated / removed records</string>
<string name="hide_invalidated_records">Hide invalidated / removed records</string>
<string name="refresh_from_nightscout">Refresh from Nightscout</string>
<string name="refresheventsfromnightscout">Refresh from NS</string>
<string name="show_invalidated">Show invalidated</string>
<string name="hide_invalidated">Hide invalidated</string>
<string name="careportal_remove_started_events">Remove AAPS started entries</string>
<string name="hide_loop">Hide loop</string>
<string name="show_loop">Show loop</string>
<string name="user_entry">User entry</string>
<string name="clone_label">Clone</string>
<string name="show_loop_records">Show loop records</string>
<string name="show_hide_records">Hide loop records</string>
</resources> </resources>