diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8198a3d374..d1c4b25958 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -69,7 +69,7 @@ android:name=".activities.PreferencesActivity" android:exported="false" /> diff --git a/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt index 2180fb1b6d..709ad6de76 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt @@ -13,15 +13,15 @@ import com.jjoe64.graphview.GraphView import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.databinding.ActivityHistorybrowseBinding -import info.nightscout.androidaps.plugins.general.overview.OverviewMenus -import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewGraph -import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData import info.nightscout.core.activities.NoSplashAppCompatActivity import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.workflow.CalculationWorkflow import info.nightscout.interfaces.Config import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.profile.DefaultValueHelper +import info.nightscout.plugins.general.overview.OverviewMenus +import info.nightscout.plugins.general.overview.events.EventUpdateOverviewGraph +import info.nightscout.plugins.general.overview.graphData.GraphData import info.nightscout.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.events.EventAutosensCalculationFinished diff --git a/app/src/main/java/info/nightscout/androidaps/di/ActivitiesModule.kt b/app/src/main/java/info/nightscout/androidaps/di/ActivitiesModule.kt index ef8eef5321..ea6261b95e 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/ActivitiesModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/ActivitiesModule.kt @@ -6,7 +6,7 @@ import info.nightscout.androidaps.MainActivity import info.nightscout.androidaps.activities.HistoryBrowseActivity import info.nightscout.androidaps.activities.PreferencesActivity import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSettingActivity -import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity +import info.nightscout.plugins.general.overview.activities.QuickWizardListActivity import info.nightscout.ui.activities.SingleFragmentActivity @Module diff --git a/app/src/main/java/info/nightscout/androidaps/di/AppComponent.kt b/app/src/main/java/info/nightscout/androidaps/di/AppComponent.kt index ea32c41a5b..50dcc8af36 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/AppComponent.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/AppComponent.kt @@ -52,6 +52,7 @@ import javax.inject.Singleton // Gradle modules AutomationModule::class, + AutomationModule.Bindings::class, ApsModule::class, ConfigurationModule::class, ConfigurationModule.Bindings::class, diff --git a/app/src/main/java/info/nightscout/androidaps/di/AppModule.kt b/app/src/main/java/info/nightscout/androidaps/di/AppModule.kt index a2876990ad..be04c3d699 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/AppModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/AppModule.kt @@ -9,43 +9,13 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.implementations.ActivityNamesImpl import info.nightscout.androidaps.implementations.ConfigImpl -import info.nightscout.configuration.configBuilder.ConfigBuilderPlugin -import info.nightscout.implementation.profile.ProfileFunctionImpl import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefsImpl import info.nightscout.androidaps.workflow.CalculationWorkflowImpl -import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.workflow.CalculationWorkflow -import info.nightscout.database.impl.AppRepository -import info.nightscout.implementation.constraints.ConstraintsImpl import info.nightscout.interfaces.Config -import info.nightscout.interfaces.ConfigBuilder -import info.nightscout.interfaces.aps.Loop -import info.nightscout.interfaces.autotune.Autotune -import info.nightscout.interfaces.constraints.Constraints -import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.maintenance.ImportExportPrefs -import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.PluginBase -import info.nightscout.interfaces.profile.ProfileFunction -import info.nightscout.interfaces.smsCommunicator.SmsCommunicator -import info.nightscout.interfaces.storage.FileStorage -import info.nightscout.interfaces.storage.Storage -import info.nightscout.interfaces.sync.DataSyncSelector import info.nightscout.interfaces.ui.ActivityNames -import info.nightscout.interfaces.utils.HardLimits -import info.nightscout.plugins.aps.loop.LoopPlugin -import info.nightscout.plugins.general.autotune.AutotunePlugin -import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin -import info.nightscout.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin -import info.nightscout.plugins.sync.nsclient.DataSyncSelectorImplementation -import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData -import info.nightscout.rx.AapsSchedulers -import info.nightscout.rx.bus.RxBus -import info.nightscout.rx.logging.AAPSLogger -import info.nightscout.shared.interfaces.ResourceHelper -import info.nightscout.shared.sharedPreferences.SP -import info.nightscout.shared.utils.DateUtil -import javax.inject.Singleton @Suppress("unused") @Module( @@ -73,27 +43,6 @@ open class AppModule { return plugins.toList().sortedBy { it.first }.map { it.second } } - @Provides - @Singleton - fun provideStorage(): Storage = FileStorage() - - @Provides - @Singleton - fun provideProfileFunction( - aapsLogger: AAPSLogger, sp: SP, rxBus: RxBus, rh: - ResourceHelper, activePlugin: - ActivePlugin, repository: AppRepository, dateUtil: DateUtil, config: Config, hardLimits: HardLimits, - aapsSchedulers: AapsSchedulers, fabricPrivacy: FabricPrivacy, processedDeviceStatusData: ProcessedDeviceStatusData - ): ProfileFunction = - ProfileFunctionImpl( - aapsLogger, sp, rxBus, rh, activePlugin, repository, dateUtil, - config, hardLimits, aapsSchedulers, fabricPrivacy, processedDeviceStatusData - ) - - @Provides - @Singleton - internal fun provideConstraints(activePlugin: ActivePlugin): Constraints = ConstraintsImpl(activePlugin) - @Module interface AppBindings { @@ -101,13 +50,7 @@ open class AppModule { @Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector @Binds fun bindConfigInterface(config: ConfigImpl): Config - @Binds fun bindConfigBuilderInterface(configBuilderPlugin: ConfigBuilderPlugin): ConfigBuilder @Binds fun bindImportExportPrefsInterface(importExportPrefs: ImportExportPrefsImpl): ImportExportPrefs - @Binds fun bindLoopInterface(loopPlugin: LoopPlugin): Loop - @Binds fun bindAutotuneInterface(autotunePlugin: AutotunePlugin): Autotune - @Binds fun bindIobCobCalculatorInterface(iobCobCalculatorPlugin: IobCobCalculatorPlugin): IobCobCalculator - @Binds fun bindSmsCommunicatorInterface(smsCommunicatorPlugin: SmsCommunicatorPlugin): SmsCommunicator - @Binds fun bindDataSyncSelectorInterface(dataSyncSelectorImplementation: DataSyncSelectorImplementation): DataSyncSelector @Binds fun bindActivityNamesInterface(activityNames: ActivityNamesImpl): ActivityNames @Binds fun bindCalculationWorkflowInterface(calculationWorkflow: CalculationWorkflowImpl): CalculationWorkflow } diff --git a/app/src/main/java/info/nightscout/androidaps/di/FragmentsModule.kt b/app/src/main/java/info/nightscout/androidaps/di/FragmentsModule.kt index 47ecaf177b..f3241a03c6 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/FragmentsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/FragmentsModule.kt @@ -3,10 +3,10 @@ package info.nightscout.androidaps.di import dagger.Module import dagger.android.ContributesAndroidInjector import info.nightscout.androidaps.activities.MyPreferenceFragment -import info.nightscout.configuration.configBuilder.ConfigBuilderFragment import info.nightscout.androidaps.plugins.general.maintenance.MaintenanceFragment -import info.nightscout.androidaps.plugins.general.overview.OverviewFragment -import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog +import info.nightscout.configuration.configBuilder.ConfigBuilderFragment +import info.nightscout.plugins.general.overview.OverviewFragment +import info.nightscout.plugins.general.overview.dialogs.EditQuickWizardDialog import info.nightscout.plugins.general.wear.WearFragment @Module diff --git a/app/src/main/java/info/nightscout/androidaps/di/OverviewModule.kt b/app/src/main/java/info/nightscout/androidaps/di/OverviewModule.kt index f5f5706f2e..c6afc2f1ba 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/OverviewModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/OverviewModule.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.di import dagger.Module import dagger.android.ContributesAndroidInjector -import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData +import info.nightscout.plugins.general.overview.graphData.GraphData import info.nightscout.plugins.general.overview.notifications.NotificationWithAction @Module diff --git a/app/src/main/java/info/nightscout/androidaps/di/PluginsListModule.kt b/app/src/main/java/info/nightscout/androidaps/di/PluginsListModule.kt index a7230024b8..c9cdca5e6f 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/PluginsListModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/PluginsListModule.kt @@ -8,9 +8,7 @@ import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin import info.nightscout.androidaps.danaRv2.DanaRv2Plugin import info.nightscout.androidaps.danar.DanaRPlugin import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin -import info.nightscout.configuration.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin -import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin import info.nightscout.androidaps.plugins.pump.eopatch.EopatchPumpPlugin import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin @@ -18,22 +16,21 @@ import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin import info.nightscout.androidaps.plugins.pump.omnipod.dash.OmnipodDashPumpPlugin import info.nightscout.androidaps.plugins.pump.omnipod.eros.OmnipodErosPumpPlugin import info.nightscout.automation.AutomationPlugin +import info.nightscout.configuration.configBuilder.ConfigBuilderPlugin import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.plugins.aps.loop.LoopPlugin import info.nightscout.plugins.aps.openAPSAMA.OpenAPSAMAPlugin import info.nightscout.plugins.aps.openAPSSMB.OpenAPSSMBPlugin import info.nightscout.plugins.aps.openAPSSMBDynamicISF.OpenAPSSMBDynamicISFPlugin import info.nightscout.plugins.constraints.bgQualityCheck.BgQualityCheckPlugin -import info.nightscout.plugins.constraints.dstHelper.DstHelperPlugin import info.nightscout.plugins.constraints.objectives.ObjectivesPlugin import info.nightscout.plugins.constraints.safety.SafetyPlugin import info.nightscout.plugins.constraints.signatureVerifier.SignatureVerifierPlugin -import info.nightscout.plugins.constraints.storage.StorageConstraintPlugin -import info.nightscout.plugins.constraints.versionChecker.VersionCheckerPlugin import info.nightscout.plugins.general.actions.ActionsPlugin import info.nightscout.plugins.general.autotune.AutotunePlugin import info.nightscout.plugins.general.dataBroadcaster.DataBroadcastPlugin import info.nightscout.plugins.general.food.FoodPlugin +import info.nightscout.plugins.general.overview.OverviewPlugin import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin import info.nightscout.plugins.general.themes.ThemeSwitcherPlugin import info.nightscout.plugins.general.wear.WearPlugin diff --git a/app/src/main/java/info/nightscout/androidaps/implementations/ActivityNamesImpl.kt b/app/src/main/java/info/nightscout/androidaps/implementations/ActivityNamesImpl.kt index 0565341a50..cc22166bd2 100644 --- a/app/src/main/java/info/nightscout/androidaps/implementations/ActivityNamesImpl.kt +++ b/app/src/main/java/info/nightscout/androidaps/implementations/ActivityNamesImpl.kt @@ -20,13 +20,18 @@ import info.nightscout.ui.activities.ErrorHelperActivity import info.nightscout.ui.activities.SingleFragmentActivity import info.nightscout.ui.activities.TDDStatsActivity import info.nightscout.ui.dialogs.BolusProgressDialog +import info.nightscout.ui.dialogs.CalibrationDialog +import info.nightscout.ui.dialogs.CarbsDialog import info.nightscout.ui.dialogs.CareDialog import info.nightscout.ui.dialogs.ExtendedBolusDialog import info.nightscout.ui.dialogs.FillDialog +import info.nightscout.ui.dialogs.InsulinDialog +import info.nightscout.ui.dialogs.LoopDialog import info.nightscout.ui.dialogs.ProfileSwitchDialog import info.nightscout.ui.dialogs.ProfileViewerDialog import info.nightscout.ui.dialogs.TempBasalDialog import info.nightscout.ui.dialogs.TempTargetDialog +import info.nightscout.ui.dialogs.TreatmentDialog import info.nightscout.ui.dialogs.WizardDialog import javax.inject.Inject @@ -52,16 +57,22 @@ class ActivityNamesImpl @Inject constructor( ctx.startActivity(i) } - override fun runWizard(fragmentManager: FragmentManager, carbs: Int, name: String) { + override fun runWizardDialog(fragmentManager: FragmentManager, carbs: Int?, name: String?) { WizardDialog().also { dialog -> dialog.arguments = Bundle().also { bundle -> - bundle.putDouble("carbs_input", carbs.toDouble()) - bundle.putString("notes_input", " $name - ${carbs}g") + carbs?.let { bundle.putDouble("carbs_input", carbs.toDouble())} + name?.let {bundle.putString("notes_input", " $name - ${carbs}g") } } }.show(fragmentManager, "Food Item") } + override fun runLoopDialog(fragmentManager: FragmentManager, showOkCancel: Int) { + LoopDialog() + .also { it.arguments = Bundle().also { bundle -> bundle.putInt("showOkCancel", showOkCancel) } } + .show(fragmentManager, "LoopDialog") + } + override fun runProfileSwitchDialog(fragmentManager: FragmentManager, profileName: String?) { ProfileSwitchDialog() .also { it.arguments = Bundle().also { bundle -> bundle.putString("profileName", profileName) } } @@ -73,6 +84,26 @@ class ActivityNamesImpl @Inject constructor( .show(fragmentManager, "TempBasalDialog") } + override fun runTreatmentDialog(fragmentManager: FragmentManager) { + TreatmentDialog() + .show(fragmentManager, "TreatmentDialog") + } + + override fun runInsulinDialog(fragmentManager: FragmentManager) { + InsulinDialog() + .show(fragmentManager, "InsulinDialog") + } + + override fun runCalibrationDialog(fragmentManager: FragmentManager) { + CalibrationDialog() + .show(fragmentManager, "CalibrationDialog") + } + + override fun runCarbsDialog(fragmentManager: FragmentManager) { + CarbsDialog() + .show(fragmentManager, "CarbsDialog") + } + override fun runTempTargetDialog(fragmentManager: FragmentManager) { TempTargetDialog() .show(fragmentManager, "TempTargetDialog") diff --git a/app/src/main/java/info/nightscout/androidaps/workflow/PrepareIobAutosensGraphDataWorker.kt b/app/src/main/java/info/nightscout/androidaps/workflow/PrepareIobAutosensGraphDataWorker.kt index 4b73b784e9..a6f2fa3809 100644 --- a/app/src/main/java/info/nightscout/androidaps/workflow/PrepareIobAutosensGraphDataWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/workflow/PrepareIobAutosensGraphDataWorker.kt @@ -10,7 +10,6 @@ import com.jjoe64.graphview.series.BarGraphSeries import com.jjoe64.graphview.series.LineGraphSeries import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.plugins.general.overview.OverviewMenus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensDataObject import info.nightscout.core.graph.OverviewData import info.nightscout.core.graph.data.DataPointWithLabelInterface @@ -31,6 +30,7 @@ import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobTotal import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.utils.DecimalFormatter +import info.nightscout.plugins.general.overview.OverviewMenus import info.nightscout.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.rx.bus.RxBus import info.nightscout.rx.logging.AAPSLogger diff --git a/app/src/main/java/info/nightscout/androidaps/workflow/PreparePredictionsWorker.kt b/app/src/main/java/info/nightscout/androidaps/workflow/PreparePredictionsWorker.kt index ae2e0bb1aa..fb9a7faabc 100644 --- a/app/src/main/java/info/nightscout/androidaps/workflow/PreparePredictionsWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/workflow/PreparePredictionsWorker.kt @@ -5,7 +5,6 @@ import androidx.work.Worker import androidx.work.WorkerParameters import androidx.work.workDataOf import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.plugins.general.overview.OverviewMenus import info.nightscout.core.graph.OverviewData import info.nightscout.core.graph.data.DataPointWithLabelInterface import info.nightscout.core.graph.data.GlucoseValueDataPoint @@ -14,9 +13,10 @@ import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.database.impl.AppRepository import info.nightscout.interfaces.Config import info.nightscout.interfaces.aps.Loop +import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData import info.nightscout.interfaces.profile.DefaultValueHelper import info.nightscout.interfaces.profile.ProfileFunction -import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData +import info.nightscout.plugins.general.overview.OverviewMenus import info.nightscout.rx.bus.RxBus import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.utils.T diff --git a/app/src/main/java/info/nightscout/androidaps/workflow/UpdateGraphWorker.kt b/app/src/main/java/info/nightscout/androidaps/workflow/UpdateGraphWorker.kt index 6ab39bac05..5d23876f9c 100644 --- a/app/src/main/java/info/nightscout/androidaps/workflow/UpdateGraphWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/workflow/UpdateGraphWorker.kt @@ -4,9 +4,9 @@ import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin -import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewGraph import info.nightscout.core.workflow.CalculationWorkflow +import info.nightscout.plugins.general.overview.OverviewPlugin +import info.nightscout.plugins.general.overview.events.EventUpdateOverviewGraph import info.nightscout.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.rx.bus.RxBus import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/workflow/UpdateIobCobSensWorker.kt b/app/src/main/java/info/nightscout/androidaps/workflow/UpdateIobCobSensWorker.kt index f1ddd358d6..4beaf02e4b 100644 --- a/app/src/main/java/info/nightscout/androidaps/workflow/UpdateIobCobSensWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/workflow/UpdateIobCobSensWorker.kt @@ -4,9 +4,9 @@ import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin -import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewIobCob -import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewSensitivity +import info.nightscout.plugins.general.overview.OverviewPlugin +import info.nightscout.plugins.general.overview.events.EventUpdateOverviewIobCob +import info.nightscout.plugins.general.overview.events.EventUpdateOverviewSensitivity import info.nightscout.rx.bus.RxBus import javax.inject.Inject diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c1b3da6cbf..90ca32b6ab 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -37,13 +37,8 @@ Reset Databases Do you really want to reset the databases? Exit - Displays the current state of your loop and buttons for most common actions Shows an ongoing notification with a short overview of what your loop is doing Delta - Overview - Treatments - Constraints violation - Change your input! Profile Nightscout version: Preferences exported @@ -64,35 +59,13 @@ As a result of successful import current master password WILL BE REPLACED with that old master password! Save Reload profile - QuickWizard settings - Button text: - Carbs: - Valid: - Add - Edit Corr (DANGEROUS TO DISABLE) NS upload only NS upload only (disabled sync). Not effective on SGV unless a local source like xDrip+ is selected. Not effective on Profiles while NS-Profiles is used.\n!!! WARNING !!! Disabling this option may cause malfunctions and insulin overdose if any of your component (AAPS, NS, xDrip+) is wrong configured. Carefully watch if data displayed by AAPS match the pump state! - Range for Visualization - High and low mark for the charts in Overview and Smartwatch - LOW mark - HIGH mark Wear Ongoing Notification OLD DATA - HOME - TREAT - Shorten tab titles Exiting application to apply settings. - Enable superbolus in wizard - Enable superbolus functionality in wizard. Do not enable until you learn what it really does. IT MAY CAUSE INSULIN OVERDOSE IF USED BLINDLY! - PRED - BAS - DEV - ACT - -BGI - ABS - DEVSLOPE About Missing phone state permission Alarm options @@ -104,70 +77,19 @@ Create notifications from NS announcements Stale data threshold [min] Urgent stale data threshold [min] - OpenAPS - Uploader - Keep screen on - Prevent Android to turn screen off. It will consume lot of energy when not plugged to power outlet. By turning on Autosense feature remember to enter all eated carbs. Otherwise carbs deviations will be identified wrong as sensitivity change !! Not all profiles loaded! Values not stored! INVALID - Default Temp-Targets - eatingsoon duration - eatingsoon target - activity duration - activity target - hypo duration - hypo target Gradually increase the volume for alerts and notifications Local alerts Alert if no BG data is received Alert if pump is unreachable Pump unreachable threshold [min] Alert if carbs are required - BG calculation - Bolus IOB calculation - Basal IOB calculation - Trend calculation - Superbolus calculation - Positive only - Negative only - COB calculation - Temporary target calculation - Percentage calculation - Buttons - show_calibration_button - show_cgm_button - show_carbs_button - show_wizard_button - show_insulin_button - show_treatment_button - Sends a calibration to xDrip+ or open BYODA calibration dialog - Opens xDrip+ or BYODA, back buttons returns to AAPS - Number of carbs to add when button is pressed - Amount of insulin to add when button is pressed - Could not launch CGM application. Make sure it is installed. - Please update your Dexcom app to supported version - Dexcom app is not installed. - Activity - Blood Glucose Impact - Sensitivity - Deviations - Carbs On Board - Insulin On Board - Basals Engineering mode enabled - Show notes field in treatment dialogs - First insulin increment - Second insulin increment - Third insulin increment - First carbs increment - Second carbs increment - Third carbs increment - CGM Open navigation Close navigation - keep_screen_on Remove items Sort items Treatment data incomplete @@ -188,49 +110,27 @@ Miscellaneous Log settings Reset to defaults - short_tabtitles == ∑ %1$s U - Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm. Units Show removed Clear queue? All data in queue will be lost! Chart menu - Predictions - Treatments - Deviation slope - graphconfig Authorization failed - Absolute insulin Unable to create profile. Profile is invalid. Don\'t kill my app? Time to eat!\nRun Bolus wizard and do calculation again. - Enable bolus reminder - Use reminder to bolus later with wizard ("post-bolus") Crash logs upload disabled! - Graph Clear filter Cannula Email address - BG data status Remove BG readings Identification not set in dev mode dialog - Not available - Show entry on device: Unknown action command: - Percentage - Application default Remove selected items %1$d selected Sort - Graph scale - All - Phone - Watch - only on watch - only on phone - drag and drop handle Search Database cleanup diff --git a/core/core-main/src/main/res/values/strings.xml b/core/core-main/src/main/res/values/strings.xml index 2e1d9d8670..c5153e33ff 100644 --- a/core/core-main/src/main/res/values/strings.xml +++ b/core/core-main/src/main/res/values/strings.xml @@ -59,7 +59,7 @@ Loading … Notes Remove - Add new + Add new Add new above Data is coming from different pump. Change pump driver to reset pump state. BG diff --git a/core/interfaces/src/main/java/info/nightscout/interfaces/automation/Automation.kt b/core/interfaces/src/main/java/info/nightscout/interfaces/automation/Automation.kt new file mode 100644 index 0000000000..9f26a97cda --- /dev/null +++ b/core/interfaces/src/main/java/info/nightscout/interfaces/automation/Automation.kt @@ -0,0 +1,6 @@ +package info.nightscout.interfaces.automation + +interface Automation { + fun userEvents(): List + fun processEvent(someEvent: AutomationEvent) +} \ No newline at end of file diff --git a/core/interfaces/src/main/java/info/nightscout/interfaces/automation/AutomationEvent.kt b/core/interfaces/src/main/java/info/nightscout/interfaces/automation/AutomationEvent.kt new file mode 100644 index 0000000000..c918d5e133 --- /dev/null +++ b/core/interfaces/src/main/java/info/nightscout/interfaces/automation/AutomationEvent.kt @@ -0,0 +1,8 @@ +package info.nightscout.interfaces.automation + +interface AutomationEvent { + var isEnabled: Boolean + var title: String + fun canRun(): Boolean + fun preconditionCanRun() : Boolean +} \ No newline at end of file diff --git a/core/interfaces/src/main/java/info/nightscout/interfaces/bgQualityCheck/BgQualityCheck.kt b/core/interfaces/src/main/java/info/nightscout/interfaces/bgQualityCheck/BgQualityCheck.kt new file mode 100644 index 0000000000..929aecbe30 --- /dev/null +++ b/core/interfaces/src/main/java/info/nightscout/interfaces/bgQualityCheck/BgQualityCheck.kt @@ -0,0 +1,9 @@ +package info.nightscout.interfaces.bgQualityCheck + +import androidx.annotation.DrawableRes + +interface BgQualityCheck { + var message: String + @DrawableRes fun icon(): Int + fun stateDescription(): String +} \ No newline at end of file diff --git a/core/interfaces/src/main/java/info/nightscout/interfaces/ui/ActivityNames.kt b/core/interfaces/src/main/java/info/nightscout/interfaces/ui/ActivityNames.kt index dcda2f2e27..e3494f5c70 100644 --- a/core/interfaces/src/main/java/info/nightscout/interfaces/ui/ActivityNames.kt +++ b/core/interfaces/src/main/java/info/nightscout/interfaces/ui/ActivityNames.kt @@ -28,9 +28,14 @@ interface ActivityNames { * @param soundId sound resource. if == 0 alarm is not started */ fun runAlarm(ctx: Context, status: String, title: String, @RawRes soundId: Int = 0) - fun runWizard(fragmentManager: FragmentManager, carbs: Int, name: String) + fun runWizardDialog(fragmentManager: FragmentManager, carbs: Int? = null, name: String? = null) + fun runLoopDialog(fragmentManager: FragmentManager, showOkCancel: Int) fun runProfileSwitchDialog(fragmentManager: FragmentManager, profileName: String? = null) fun runTempBasalDialog(fragmentManager: FragmentManager) + fun runTreatmentDialog(fragmentManager: FragmentManager) + fun runInsulinDialog(fragmentManager: FragmentManager) + fun runCalibrationDialog(fragmentManager: FragmentManager) + fun runCarbsDialog(fragmentManager: FragmentManager) fun runTempTargetDialog(fragmentManager: FragmentManager) fun runExtendedBolusDialog(fragmentManager: FragmentManager) fun runFillDialog(fragmentManager: FragmentManager) diff --git a/plugins/automation/src/main/res/drawable/ic_add_black_24dp.xml b/core/ui/src/main/res/drawable/ic_add_black_24dp.xml similarity index 100% rename from plugins/automation/src/main/res/drawable/ic_add_black_24dp.xml rename to core/ui/src/main/res/drawable/ic_add_black_24dp.xml diff --git a/ui/src/main/res/drawable/ic_loop_disabled.xml b/core/ui/src/main/res/drawable/ic_loop_disabled.xml similarity index 100% rename from ui/src/main/res/drawable/ic_loop_disabled.xml rename to core/ui/src/main/res/drawable/ic_loop_disabled.xml diff --git a/ui/src/main/res/drawable/ic_loop_disconnected.xml b/core/ui/src/main/res/drawable/ic_loop_disconnected.xml similarity index 100% rename from ui/src/main/res/drawable/ic_loop_disconnected.xml rename to core/ui/src/main/res/drawable/ic_loop_disconnected.xml diff --git a/ui/src/main/res/drawable/ic_loop_lgs.xml b/core/ui/src/main/res/drawable/ic_loop_lgs.xml similarity index 100% rename from ui/src/main/res/drawable/ic_loop_lgs.xml rename to core/ui/src/main/res/drawable/ic_loop_lgs.xml diff --git a/ui/src/main/res/drawable/ic_loop_open.xml b/core/ui/src/main/res/drawable/ic_loop_open.xml similarity index 100% rename from ui/src/main/res/drawable/ic_loop_open.xml rename to core/ui/src/main/res/drawable/ic_loop_open.xml diff --git a/ui/src/main/res/drawable/ic_loop_paused.xml b/core/ui/src/main/res/drawable/ic_loop_paused.xml similarity index 100% rename from ui/src/main/res/drawable/ic_loop_paused.xml rename to core/ui/src/main/res/drawable/ic_loop_paused.xml diff --git a/ui/src/main/res/drawable/ic_loop_reconnect.xml b/core/ui/src/main/res/drawable/ic_loop_reconnect.xml similarity index 100% rename from ui/src/main/res/drawable/ic_loop_reconnect.xml rename to core/ui/src/main/res/drawable/ic_loop_reconnect.xml diff --git a/ui/src/main/res/drawable/ic_loop_resume.xml b/core/ui/src/main/res/drawable/ic_loop_resume.xml similarity index 100% rename from ui/src/main/res/drawable/ic_loop_resume.xml rename to core/ui/src/main/res/drawable/ic_loop_resume.xml diff --git a/plugins/automation/src/main/res/drawable/ic_reorder_gray_24dp.xml b/core/ui/src/main/res/drawable/ic_reorder_gray_24dp.xml similarity index 100% rename from plugins/automation/src/main/res/drawable/ic_reorder_gray_24dp.xml rename to core/ui/src/main/res/drawable/ic_reorder_gray_24dp.xml diff --git a/core/ui/src/main/res/values/strings.xml b/core/ui/src/main/res/values/strings.xml index 663eb22044..5c8de724c8 100644 --- a/core/ui/src/main/res/values/strings.xml +++ b/core/ui/src/main/res/values/strings.xml @@ -26,6 +26,9 @@ Snooze Virtual Pump Constraints + Superbolus + Pump paused + And Battery diff --git a/implementation/src/main/java/info/nightscout/implementation/BolusTimerImpl.kt b/implementation/src/main/java/info/nightscout/implementation/BolusTimerImpl.kt index 315fee99a9..e4d7bcf007 100644 --- a/implementation/src/main/java/info/nightscout/implementation/BolusTimerImpl.kt +++ b/implementation/src/main/java/info/nightscout/implementation/BolusTimerImpl.kt @@ -1,10 +1,7 @@ package info.nightscout.implementation import dagger.android.HasAndroidInjector -import info.nightscout.interfaces.BolusTimer -import info.nightscout.interfaces.GlucoseUnit -import info.nightscout.shared.interfaces.ResourceHelper -import info.nightscout.automation.AutomationEvent +import info.nightscout.automation.AutomationEventObject import info.nightscout.automation.AutomationPlugin import info.nightscout.automation.actions.ActionAlarm import info.nightscout.automation.elements.Comparator @@ -12,6 +9,9 @@ import info.nightscout.automation.elements.InputDelta import info.nightscout.automation.triggers.TriggerBg import info.nightscout.automation.triggers.TriggerConnector import info.nightscout.automation.triggers.TriggerDelta +import info.nightscout.interfaces.BolusTimer +import info.nightscout.interfaces.GlucoseUnit +import info.nightscout.shared.interfaces.ResourceHelper import java.text.DecimalFormat import javax.inject.Inject import javax.inject.Singleton @@ -24,7 +24,7 @@ class BolusTimerImpl @Inject constructor( ) : BolusTimer { override fun scheduleAutomationEventBolusReminder() { - val event = AutomationEvent(injector).apply { + val event = AutomationEventObject(injector).apply { title = rh.gs(R.string.bolus_reminder) readOnly = true systemAction = true @@ -47,7 +47,7 @@ class BolusTimerImpl @Inject constructor( } override fun removeAutomationEventBolusReminder() { - val event = AutomationEvent(injector).apply { + val event = AutomationEventObject(injector).apply { title = rh.gs(R.string.bolus_reminder) } automationPlugin.removeIfExists(event) diff --git a/implementation/src/main/java/info/nightscout/implementation/CarbTimerImpl.kt b/implementation/src/main/java/info/nightscout/implementation/CarbTimerImpl.kt index c30797a6b9..7c492519ce 100644 --- a/implementation/src/main/java/info/nightscout/implementation/CarbTimerImpl.kt +++ b/implementation/src/main/java/info/nightscout/implementation/CarbTimerImpl.kt @@ -1,11 +1,7 @@ package info.nightscout.implementation import dagger.android.HasAndroidInjector -import info.nightscout.interfaces.CarbTimer -import info.nightscout.interfaces.GlucoseUnit -import info.nightscout.shared.interfaces.ResourceHelper -import info.nightscout.interfaces.utils.TimerUtil -import info.nightscout.automation.AutomationEvent +import info.nightscout.automation.AutomationEventObject import info.nightscout.automation.AutomationPlugin import info.nightscout.automation.actions.ActionAlarm import info.nightscout.automation.elements.Comparator @@ -13,6 +9,10 @@ import info.nightscout.automation.elements.InputDelta import info.nightscout.automation.triggers.TriggerBg import info.nightscout.automation.triggers.TriggerConnector import info.nightscout.automation.triggers.TriggerDelta +import info.nightscout.interfaces.CarbTimer +import info.nightscout.interfaces.GlucoseUnit +import info.nightscout.interfaces.utils.TimerUtil +import info.nightscout.shared.interfaces.ResourceHelper import java.text.DecimalFormat import javax.inject.Inject import javax.inject.Singleton @@ -37,7 +37,7 @@ class CarbTimerImpl @Inject constructor( * Create new Automation event to alarm when is time to eat */ override fun scheduleAutomationEventEatReminder() { - val event = AutomationEvent(injector).apply { + val event = AutomationEventObject(injector).apply { title = rh.gs(R.string.bolus_advisor) readOnly = true systemAction = true @@ -94,7 +94,7 @@ class CarbTimerImpl @Inject constructor( * Remove Automation event */ override fun removeAutomationEventEatReminder() { - val event = AutomationEvent(injector).apply { + val event = AutomationEventObject(injector).apply { title = rh.gs(R.string.bolus_advisor) } automationPlugin.removeIfExists(event) diff --git a/implementation/src/main/java/info/nightscout/implementation/di/ImplementationModule.kt b/implementation/src/main/java/info/nightscout/implementation/di/ImplementationModule.kt index 2429ebce9b..3a0028bad3 100644 --- a/implementation/src/main/java/info/nightscout/implementation/di/ImplementationModule.kt +++ b/implementation/src/main/java/info/nightscout/implementation/di/ImplementationModule.kt @@ -15,11 +15,13 @@ import info.nightscout.implementation.TrendCalculatorImpl import info.nightscout.implementation.UserEntryLoggerImpl import info.nightscout.implementation.XDripBroadcastImpl import info.nightscout.implementation.androidNotification.NotificationHolderImpl +import info.nightscout.implementation.constraints.ConstraintsImpl import info.nightscout.implementation.db.PersistenceLayerImpl import info.nightscout.implementation.logging.LoggerUtilsImpl import info.nightscout.implementation.maintenance.PrefFileListProviderImpl import info.nightscout.implementation.overview.OverviewDataImpl import info.nightscout.implementation.plugin.PluginStore +import info.nightscout.implementation.profile.ProfileFunctionImpl import info.nightscout.implementation.profile.ProfileInstantiatorImpl import info.nightscout.implementation.profile.ProfileStoreObject import info.nightscout.implementation.profiling.ProfilerImpl @@ -36,6 +38,7 @@ import info.nightscout.implementation.resources.ResourceHelperImpl import info.nightscout.implementation.stats.DexcomTirCalculatorImpl import info.nightscout.implementation.stats.TddCalculatorImpl import info.nightscout.implementation.stats.TirCalculatorImpl +import info.nightscout.implementation.storage.FileStorage import info.nightscout.interfaces.AndroidPermission import info.nightscout.interfaces.BolusTimer import info.nightscout.interfaces.CarbTimer @@ -43,12 +46,14 @@ import info.nightscout.interfaces.LocalAlertUtils import info.nightscout.interfaces.NotificationHolder import info.nightscout.interfaces.Translator import info.nightscout.interfaces.XDripBroadcast +import info.nightscout.interfaces.constraints.Constraints import info.nightscout.interfaces.db.PersistenceLayer import info.nightscout.interfaces.logging.LoggerUtils import info.nightscout.interfaces.logging.UserEntryLogger import info.nightscout.interfaces.maintenance.PrefFileListProvider import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.profile.DefaultValueHelper +import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileInstantiator import info.nightscout.interfaces.profiling.Profiler import info.nightscout.interfaces.protection.PasswordCheck @@ -62,6 +67,7 @@ import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.stats.DexcomTirCalculator import info.nightscout.interfaces.stats.TddCalculator import info.nightscout.interfaces.stats.TirCalculator +import info.nightscout.interfaces.storage.Storage import info.nightscout.interfaces.ui.IconsProvider import info.nightscout.interfaces.utils.HardLimits import info.nightscout.interfaces.utils.TrendCalculator @@ -112,5 +118,8 @@ abstract class ImplementationModule { @Binds fun bindIconsProviderInterface(iconsProvider: IconsProviderImplementation): IconsProvider @Binds fun bindNotificationHolderInterface(notificationHolder: NotificationHolderImpl): NotificationHolder @Binds fun bindCommandQueue(commandQueue: CommandQueueImplementation): CommandQueue + @Binds fun bindsConstraints(constraintsImpl: ConstraintsImpl): Constraints + @Binds fun bindsProfileFunction(profileFunctionImpl: ProfileFunctionImpl): ProfileFunction + @Binds fun bindsStorage(fileStorage: FileStorage): Storage } } \ No newline at end of file diff --git a/core/interfaces/src/main/java/info/nightscout/interfaces/storage/FileStorage.kt b/implementation/src/main/java/info/nightscout/implementation/storage/FileStorage.kt similarity index 60% rename from core/interfaces/src/main/java/info/nightscout/interfaces/storage/FileStorage.kt rename to implementation/src/main/java/info/nightscout/implementation/storage/FileStorage.kt index 05138548a5..1af639aa1c 100644 --- a/core/interfaces/src/main/java/info/nightscout/interfaces/storage/FileStorage.kt +++ b/implementation/src/main/java/info/nightscout/implementation/storage/FileStorage.kt @@ -1,10 +1,12 @@ -package info.nightscout.interfaces.storage +package info.nightscout.implementation.storage +import info.nightscout.interfaces.storage.Storage import java.io.File +import javax.inject.Inject import javax.inject.Singleton @Singleton -class FileStorage : Storage { +class FileStorage @Inject constructor(): Storage { override fun getFileContents(file: File): String { return file.readText() diff --git a/implementation/src/main/res/values/strings.xml b/implementation/src/main/res/values/strings.xml index 81c83201ed..2c7e59e60b 100644 --- a/implementation/src/main/res/values/strings.xml +++ b/implementation/src/main/res/values/strings.xml @@ -7,8 +7,6 @@ Missed BG readings Time to eat - Enable bolus advisor - Use reminder to start eating later instead of wizard result during high glycemia ("pre-bolus") Time to bolus!\nRun Bolus wizard and do calculation again. Command is executed right now Basal value below minimum. Profile not set! diff --git a/insight/src/main/res/values/strings.xml b/insight/src/main/res/values/strings.xml index a4dc38328e..3ded31385d 100644 --- a/insight/src/main/res/values/strings.xml +++ b/insight/src/main/res/values/strings.xml @@ -51,7 +51,6 @@ Timeout during handshake - reset bluetooth Pump stopped Pump started - Pump paused Last conn: %1$d min ago TBR: %1$d%% for %2$d / %3$d min Extended: %1$.2f / %2$.2f U for %3$d min diff --git a/plugins/aps/src/main/java/info/nightscout/plugins/aps/di/ApsModule.kt b/plugins/aps/src/main/java/info/nightscout/plugins/aps/di/ApsModule.kt index ff34136b4e..338c9213d4 100644 --- a/plugins/aps/src/main/java/info/nightscout/plugins/aps/di/ApsModule.kt +++ b/plugins/aps/src/main/java/info/nightscout/plugins/aps/di/ApsModule.kt @@ -1,18 +1,29 @@ package info.nightscout.plugins.aps.di +import dagger.Binds import dagger.Module import dagger.android.ContributesAndroidInjector +import info.nightscout.interfaces.autotune.Autotune import info.nightscout.plugins.aps.OpenAPSFragment -import info.nightscout.plugins.di.AutotuneModule +import info.nightscout.plugins.general.autotune.AutotunePlugin @Module( includes = [ AutotuneModule::class, - AlgModule::class + AlgModule::class, + + ApsModule.Bindings::class ] ) @Suppress("unused") abstract class ApsModule { + @ContributesAndroidInjector abstract fun contributesOpenAPSFragment(): OpenAPSFragment + + @Module + interface Bindings { + + @Binds fun bindAutotuneInterface(autotunePlugin: AutotunePlugin): Autotune + } } \ No newline at end of file diff --git a/plugins/aps/src/main/java/info/nightscout/plugins/aps/di/AutotuneModule.kt b/plugins/aps/src/main/java/info/nightscout/plugins/aps/di/AutotuneModule.kt index 5f6ac3e358..0d7263a8bf 100644 --- a/plugins/aps/src/main/java/info/nightscout/plugins/aps/di/AutotuneModule.kt +++ b/plugins/aps/src/main/java/info/nightscout/plugins/aps/di/AutotuneModule.kt @@ -1,4 +1,4 @@ -package info.nightscout.plugins.di +package info.nightscout.plugins.aps.di import dagger.Module import dagger.android.ContributesAndroidInjector diff --git a/plugins/automation/src/main/java/info/nightscout/automation/AutomationEvent.kt b/plugins/automation/src/main/java/info/nightscout/automation/AutomationEvent.kt index 3ad795dd31..21667d7269 100644 --- a/plugins/automation/src/main/java/info/nightscout/automation/AutomationEvent.kt +++ b/plugins/automation/src/main/java/info/nightscout/automation/AutomationEvent.kt @@ -1,25 +1,26 @@ package info.nightscout.automation import dagger.android.HasAndroidInjector -import info.nightscout.shared.utils.DateUtil -import info.nightscout.shared.utils.T import info.nightscout.automation.actions.Action import info.nightscout.automation.actions.ActionDummy import info.nightscout.automation.actions.ActionStopProcessing import info.nightscout.automation.triggers.TriggerConnector import info.nightscout.automation.triggers.TriggerDummy +import info.nightscout.interfaces.automation.AutomationEvent import info.nightscout.rx.logging.AAPSLogger +import info.nightscout.shared.utils.DateUtil +import info.nightscout.shared.utils.T import org.json.JSONArray import org.json.JSONObject import javax.inject.Inject -class AutomationEvent(private val injector: HasAndroidInjector) { +class AutomationEventObject(private val injector: HasAndroidInjector) : AutomationEvent { @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var dateUtil: DateUtil - var title: String = "" - var isEnabled = true + override var title: String = "" + override var isEnabled = true var position = -1 var systemAction: Boolean = false // true = generated by AAPS, false = entered by user var readOnly: Boolean = false // removing, editing disabled @@ -35,7 +36,10 @@ class AutomationEvent(private val injector: HasAndroidInjector) { injector.androidInjector().inject(this) } - fun getPreconditions(): TriggerConnector { + override fun canRun() : Boolean = trigger.shouldRun() + override fun preconditionCanRun() : Boolean = getPreconditions().shouldRun() + + internal fun getPreconditions(): TriggerConnector { val trigger = TriggerConnector(injector, TriggerConnector.Type.AND) for (action in actions) { action.precondition?.let { trigger.list.add(it) } @@ -72,7 +76,7 @@ class AutomationEvent(private val injector: HasAndroidInjector) { .toString() } - fun fromJSON(data: String, position: Int): AutomationEvent { + fun fromJSON(data: String, position: Int): AutomationEventObject { val d = JSONObject(data) title = d.optString("title", "") isEnabled = d.optBoolean("enabled", true) diff --git a/plugins/automation/src/main/java/info/nightscout/automation/AutomationFragment.kt b/plugins/automation/src/main/java/info/nightscout/automation/AutomationFragment.kt index 9e75ca7226..238c670335 100644 --- a/plugins/automation/src/main/java/info/nightscout/automation/AutomationFragment.kt +++ b/plugins/automation/src/main/java/info/nightscout/automation/AutomationFragment.kt @@ -66,7 +66,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener, MenuProvider { private var disposable: CompositeDisposable = CompositeDisposable() private lateinit var eventListAdapter: EventListAdapter - private lateinit var actionHelper: ActionModeHelper + private lateinit var actionHelper: ActionModeHelper private val itemTouchHelper = ItemTouchHelper(SimpleItemTouchHelperCallback()) private var _binding: AutomationFragmentBinding? = null @@ -286,7 +286,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener, MenuProvider { } } - private fun getConfirmationText(selectedItems: SparseArray): String { + private fun getConfirmationText(selectedItems: SparseArray): String { if (selectedItems.size() == 1) { val event = selectedItems.valueAt(0) return rh.gs(R.string.removerecord) + " " + event.title @@ -294,7 +294,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener, MenuProvider { return rh.gs(R.string.confirm_remove_multiple_items, selectedItems.size()) } - private fun removeSelected(selectedItems: SparseArray) { + private fun removeSelected(selectedItems: SparseArray) { activity?.let { activity -> OKDialog.showConfirmation(activity, rh.gs(R.string.removerecord), getConfirmationText(selectedItems), Runnable { selectedItems.forEach { _, event -> @@ -311,7 +311,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener, MenuProvider { actionHelper.finish() EditEventDialog().also { it.arguments = Bundle().apply { - putString("event", AutomationEvent(injector).toJSON()) + putString("event", AutomationEventObject(injector).toJSON()) putInt("position", -1) // New event } }.show(childFragmentManager, "EditEventDialog") diff --git a/plugins/automation/src/main/java/info/nightscout/automation/AutomationPlugin.kt b/plugins/automation/src/main/java/info/nightscout/automation/AutomationPlugin.kt index 8c70fc228b..7d0509cac5 100644 --- a/plugins/automation/src/main/java/info/nightscout/automation/AutomationPlugin.kt +++ b/plugins/automation/src/main/java/info/nightscout/automation/AutomationPlugin.kt @@ -42,6 +42,8 @@ import info.nightscout.automation.triggers.TriggerWifiSsid import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.interfaces.Config import info.nightscout.interfaces.aps.Loop +import info.nightscout.interfaces.automation.Automation +import info.nightscout.interfaces.automation.AutomationEvent import info.nightscout.interfaces.constraints.Constraints import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.PluginBase @@ -98,13 +100,13 @@ class AutomationPlugin @Inject constructor( .preferencesId(R.xml.pref_automation) .description(R.string.automation_description), aapsLogger, rh, injector -) { +), Automation { private var disposable: CompositeDisposable = CompositeDisposable() private val keyAutomationEvents = "AUTOMATION_EVENTS" - private val automationEvents = ArrayList() + private val automationEvents = ArrayList() var executionLog: MutableList = ArrayList() var btConnects: MutableList = ArrayList() @@ -202,14 +204,14 @@ class AutomationPlugin @Inject constructor( val array = JSONArray(data) for (i in 0 until array.length()) { val o = array.getJSONObject(i) - val event = AutomationEvent(injector).fromJSON(o.toString(), i) + val event = AutomationEventObject(injector).fromJSON(o.toString(), i) automationEvents.add(event) } } catch (e: JSONException) { e.printStackTrace() } else - automationEvents.add(AutomationEvent(injector).fromJSON(event, 0)) + automationEvents.add(AutomationEventObject(injector).fromJSON(event, 0)) } internal fun processActions() { @@ -259,8 +261,9 @@ class AutomationPlugin @Inject constructor( storeToSP() // save last run time } - fun processEvent(event: AutomationEvent) { - if (event.trigger.shouldRun() && event.getPreconditions().shouldRun()) { + override fun processEvent(someEvent: AutomationEvent) { + val event = someEvent as AutomationEventObject + if (event.canRun() && event.preconditionCanRun()) { val actions = event.actions for (action in actions) { action.title = event.title @@ -296,14 +299,14 @@ class AutomationPlugin @Inject constructor( } @Synchronized - fun add(event: AutomationEvent) { + fun add(event: AutomationEventObject) { automationEvents.add(event) event.position = automationEvents.size - 1 rxBus.send(EventAutomationDataChanged()) } @Synchronized - fun addIfNotExists(event: AutomationEvent) { + fun addIfNotExists(event: AutomationEventObject) { for (e in automationEvents) { if (event.title == e.title) return } @@ -322,7 +325,7 @@ class AutomationPlugin @Inject constructor( } @Synchronized - fun set(event: AutomationEvent, index: Int) { + fun set(event: AutomationEventObject, index: Int) { automationEvents[index] = event rxBus.send(EventAutomationDataChanged()) } @@ -349,7 +352,7 @@ class AutomationPlugin @Inject constructor( Collections.swap(automationEvents, fromPosition, toPosition) } - fun userEvents(): List { + override fun userEvents(): List { val list = mutableListOf() val iterator = synchronized(this) { automationEvents.toMutableList().iterator() } while (iterator.hasNext()) { diff --git a/plugins/automation/src/main/java/info/nightscout/automation/di/AutomationModule.kt b/plugins/automation/src/main/java/info/nightscout/automation/di/AutomationModule.kt index be20c322e1..c6e8207c31 100644 --- a/plugins/automation/src/main/java/info/nightscout/automation/di/AutomationModule.kt +++ b/plugins/automation/src/main/java/info/nightscout/automation/di/AutomationModule.kt @@ -1,9 +1,11 @@ package info.nightscout.automation.di +import dagger.Binds import dagger.Module import dagger.android.ContributesAndroidInjector -import info.nightscout.automation.AutomationEvent +import info.nightscout.automation.AutomationEventObject import info.nightscout.automation.AutomationFragment +import info.nightscout.automation.AutomationPlugin import info.nightscout.automation.actions.Action import info.nightscout.automation.actions.ActionAlarm import info.nightscout.automation.actions.ActionCarePortalEvent @@ -45,6 +47,7 @@ import info.nightscout.automation.triggers.TriggerTempTargetValue import info.nightscout.automation.triggers.TriggerTime import info.nightscout.automation.triggers.TriggerTimeRange import info.nightscout.automation.triggers.TriggerWifiSsid +import info.nightscout.interfaces.automation.Automation @Module @Suppress("unused") @@ -57,7 +60,7 @@ abstract class AutomationModule { @ContributesAndroidInjector abstract fun contributesEditActionDialog(): EditActionDialog @ContributesAndroidInjector abstract fun contributesEditEventDialog(): EditEventDialog @ContributesAndroidInjector abstract fun contributesEditTriggerDialog(): EditTriggerDialog - @ContributesAndroidInjector abstract fun automationEventInjector(): AutomationEvent + @ContributesAndroidInjector abstract fun automationEventInjector(): AutomationEventObject @ContributesAndroidInjector abstract fun triggerInjector(): Trigger @ContributesAndroidInjector abstract fun triggerAutosensValueInjector(): TriggerAutosensValue @@ -95,4 +98,10 @@ abstract class AutomationModule { @ContributesAndroidInjector abstract fun actionStartTempTargetInjector(): ActionStartTempTarget @ContributesAndroidInjector abstract fun actionStopTempTargetInjector(): ActionStopTempTarget @ContributesAndroidInjector abstract fun actionDummyInjector(): ActionDummy + + @Module + interface Bindings { + + @Binds fun bindAutomation(automationPlugin: AutomationPlugin): Automation + } } \ No newline at end of file diff --git a/plugins/automation/src/main/java/info/nightscout/automation/dialogs/EditEventDialog.kt b/plugins/automation/src/main/java/info/nightscout/automation/dialogs/EditEventDialog.kt index 4d62af9a7f..3db69b1749 100644 --- a/plugins/automation/src/main/java/info/nightscout/automation/dialogs/EditEventDialog.kt +++ b/plugins/automation/src/main/java/info/nightscout/automation/dialogs/EditEventDialog.kt @@ -10,7 +10,7 @@ import android.widget.TextView import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import dagger.android.HasAndroidInjector -import info.nightscout.automation.AutomationEvent +import info.nightscout.automation.AutomationEventObject import info.nightscout.automation.AutomationPlugin import info.nightscout.automation.R import info.nightscout.automation.actions.Action @@ -38,7 +38,7 @@ class EditEventDialog : BaseDialog() { @Inject lateinit var automationPlugin: AutomationPlugin private var actionListAdapter: ActionListAdapter? = null - private lateinit var event: AutomationEvent + private lateinit var event: AutomationEventObject private var position: Int = -1 private var disposable: CompositeDisposable = CompositeDisposable() @@ -53,11 +53,11 @@ class EditEventDialog : BaseDialog() { inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { - event = AutomationEvent(injector) + event = AutomationEventObject(injector) // load data from bundle (savedInstanceState ?: arguments)?.let { bundle -> position = bundle.getInt("position", -1) - bundle.getString("event")?.let { event = AutomationEvent(injector).fromJSON(it, position) } + bundle.getString("event")?.let { event = AutomationEventObject(injector).fromJSON(it, position) } } onCreateViewGeneral() diff --git a/plugins/automation/src/main/res/values/strings.xml b/plugins/automation/src/main/res/values/strings.xml index e0a2068cd5..fc9cf5dded 100644 --- a/plugins/automation/src/main/res/values/strings.xml +++ b/plugins/automation/src/main/res/values/strings.xml @@ -44,7 +44,6 @@ Temp Target %1$s %2$.1f %3$s Profile pct %1$s %2$d IOB %1$s %2$.1f - And Or Exclusive or At %1$s diff --git a/plugins/automation/src/test/java/info/nightscout/automation/AutomationEventTest.kt b/plugins/automation/src/test/java/info/nightscout/automation/AutomationEventTest.kt index 33d4f3786c..cb3503b554 100644 --- a/plugins/automation/src/test/java/info/nightscout/automation/AutomationEventTest.kt +++ b/plugins/automation/src/test/java/info/nightscout/automation/AutomationEventTest.kt @@ -26,7 +26,7 @@ class AutomationEventTest : TestBase() { var injector: HasAndroidInjector = HasAndroidInjector { AndroidInjector { - if (it is AutomationEvent) { + if (it is AutomationEventObject) { it.aapsLogger = aapsLogger } if (it is Action) { @@ -44,7 +44,7 @@ class AutomationEventTest : TestBase() { @Test fun testCloneEvent() { // create test object - val event = AutomationEvent(injector) + val event = AutomationEventObject(injector) event.title = "Test" event.trigger = TriggerDummy(injector).instantiate(JSONObject(TriggerConnectorTest.oneItem)) as TriggerConnector event.addAction(ActionLoopEnable(injector)) @@ -55,7 +55,7 @@ class AutomationEventTest : TestBase() { Assert.assertEquals(eventJsonExpected, event.toJSON()) // clone - val clone = AutomationEvent(injector).fromJSON(eventJsonExpected, 1) + val clone = AutomationEventObject(injector).fromJSON(eventJsonExpected, 1) // check title Assert.assertEquals(event.title, clone.title) @@ -74,7 +74,7 @@ class AutomationEventTest : TestBase() { @Test fun hasStopProcessing() { - val event = AutomationEvent(injector) + val event = AutomationEventObject(injector) event.title = "Test" event.trigger = TriggerDummy(injector).instantiate(JSONObject(TriggerConnectorTest.oneItem)) as TriggerConnector Assert.assertFalse(event.hasStopProcessing()) diff --git a/plugins/configuration/src/main/java/info/nightscout/configuration/di/ConfigurationModule.kt b/plugins/configuration/src/main/java/info/nightscout/configuration/di/ConfigurationModule.kt index f31d80903c..cab927638c 100644 --- a/plugins/configuration/src/main/java/info/nightscout/configuration/di/ConfigurationModule.kt +++ b/plugins/configuration/src/main/java/info/nightscout/configuration/di/ConfigurationModule.kt @@ -2,7 +2,9 @@ package info.nightscout.configuration.di import dagger.Binds import dagger.Module +import info.nightscout.configuration.configBuilder.ConfigBuilderPlugin import info.nightscout.configuration.configBuilder.RunningConfigurationImpl +import info.nightscout.interfaces.ConfigBuilder import info.nightscout.interfaces.configBuilder.RunningConfiguration @Module( @@ -16,5 +18,6 @@ open class ConfigurationModule { interface Bindings { @Binds fun bindRunningConfiguration(runningConfigurationImpl: RunningConfigurationImpl): RunningConfiguration + @Binds fun bindConfigBuilderInterface(configBuilderPlugin: ConfigBuilderPlugin): ConfigBuilder } } \ No newline at end of file diff --git a/plugins/main/src/main/java/info/nightscout/plugins/di/PluginsModule.kt b/plugins/main/src/main/java/info/nightscout/plugins/di/PluginsModule.kt index bbb5701660..6deeb185d0 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/di/PluginsModule.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/di/PluginsModule.kt @@ -2,8 +2,16 @@ package info.nightscout.plugins.di import dagger.Binds import dagger.Module -import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData +import info.nightscout.interfaces.aps.Loop +import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.nsclient.NSSettingsStatus +import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData +import info.nightscout.interfaces.smsCommunicator.SmsCommunicator +import info.nightscout.interfaces.sync.DataSyncSelector +import info.nightscout.plugins.aps.loop.LoopPlugin +import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin +import info.nightscout.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin +import info.nightscout.plugins.sync.nsclient.DataSyncSelectorImplementation import info.nightscout.plugins.sync.nsclient.data.NSSettingsStatusImpl import info.nightscout.plugins.sync.nsclient.data.ProcessedDeviceStatusDataImpl @@ -33,5 +41,9 @@ abstract class PluginsModule { @Binds fun bindProcessedDeviceStatusData(processedDeviceStatusDataImpl: ProcessedDeviceStatusDataImpl): ProcessedDeviceStatusData @Binds fun bindNSSettingsStatus(nsSettingsStatusImpl: NSSettingsStatusImpl): NSSettingsStatus + @Binds fun bindSmsCommunicator(smsCommunicatorPlugin: SmsCommunicatorPlugin): SmsCommunicator + @Binds fun bindIobCobCalculator(iobCobCalculatorPlugin: IobCobCalculatorPlugin): IobCobCalculator + @Binds fun bindLoop(loopPlugin: LoopPlugin): Loop + @Binds fun bindDataSyncSelectorInterface(dataSyncSelectorImplementation: DataSyncSelectorImplementation): DataSyncSelector } } \ No newline at end of file diff --git a/plugins/main/src/main/java/info/nightscout/plugins/general/food/FoodFragment.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/food/FoodFragment.kt index d5536d5dfe..bed124e9bd 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/general/food/FoodFragment.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/food/FoodFragment.kt @@ -12,7 +12,6 @@ import android.widget.ArrayAdapter import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import dagger.android.support.DaggerFragment -import info.nightscout.interfaces.logging.UserEntryLogger import info.nightscout.core.ui.UIRunnable import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.utils.fabric.FabricPrivacy @@ -21,6 +20,7 @@ import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Sources import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.transactions.InvalidateFoodTransaction +import info.nightscout.interfaces.logging.UserEntryLogger import info.nightscout.interfaces.protection.ProtectionCheck import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.plugins.R @@ -224,7 +224,7 @@ class FoodFragment : DaggerFragment() { val food = v.tag as Food activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { - if (isAdded) activityNames.runWizard(childFragmentManager, food.carbs, food.name) + if (isAdded) activityNames.runWizardDialog(childFragmentManager, food.carbs, food.name) }) } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewFragment.kt similarity index 94% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt rename to plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewFragment.kt index 0e8b38bf14..c6ca7ee9f2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewFragment.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.overview +package info.nightscout.plugins.general.overview import android.annotation.SuppressLint import android.app.NotificationManager @@ -27,18 +27,9 @@ import androidx.recyclerview.widget.LinearLayoutManager import com.jjoe64.graphview.GraphView import dagger.android.HasAndroidInjector import dagger.android.support.DaggerFragment -import info.nightscout.androidaps.R import info.nightscout.androidaps.extensions.directionToIcon import info.nightscout.androidaps.extensions.valueToUnitsString -import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity -import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewCalcProgress -import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewGraph -import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewIobCob -import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewSensitivity -import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider -import info.nightscout.androidaps.plugins.pump.omnipod.eros.OmnipodErosPumpPlugin -import info.nightscout.automation.AutomationPlugin import info.nightscout.core.graph.OverviewData import info.nightscout.core.iob.displayText import info.nightscout.core.profile.ProfileSealed @@ -56,10 +47,15 @@ import info.nightscout.interfaces.Config import info.nightscout.interfaces.Constants import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.aps.Loop +import info.nightscout.interfaces.aps.VariableSensitivityResult +import info.nightscout.interfaces.automation.Automation +import info.nightscout.interfaces.bgQualityCheck.BgQualityCheck import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Constraints import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.logging.UserEntryLogger +import info.nightscout.interfaces.nsclient.NSSettingsStatus +import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.profile.DefaultValueHelper @@ -70,16 +66,20 @@ import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.TrendCalculator +import info.nightscout.plugins.R import info.nightscout.plugins.aps.loop.events.EventNewOpenLoopNotification -import info.nightscout.plugins.constraints.bgQualityCheck.BgQualityCheckPlugin import info.nightscout.plugins.databinding.OverviewFragmentBinding +import info.nightscout.plugins.general.overview.activities.QuickWizardListActivity +import info.nightscout.plugins.general.overview.events.EventUpdateOverviewCalcProgress +import info.nightscout.plugins.general.overview.events.EventUpdateOverviewGraph +import info.nightscout.plugins.general.overview.events.EventUpdateOverviewIobCob +import info.nightscout.plugins.general.overview.events.EventUpdateOverviewSensitivity +import info.nightscout.plugins.general.overview.graphData.GraphData import info.nightscout.plugins.general.overview.notifications.NotificationStore import info.nightscout.plugins.general.overview.notifications.events.EventUpdateOverviewNotification import info.nightscout.plugins.skins.SkinProvider import info.nightscout.plugins.source.DexcomPlugin import info.nightscout.plugins.source.XdripPlugin -import info.nightscout.interfaces.nsclient.NSSettingsStatus -import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData import info.nightscout.plugins.ui.StatusLightHandler import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus @@ -101,14 +101,6 @@ import info.nightscout.shared.extensions.toVisibility import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil -import info.nightscout.ui.dialogs.CalibrationDialog -import info.nightscout.ui.dialogs.CarbsDialog -import info.nightscout.ui.dialogs.InsulinDialog -import info.nightscout.ui.dialogs.LoopDialog -import info.nightscout.ui.dialogs.ProfileSwitchDialog -import info.nightscout.ui.dialogs.TempTargetDialog -import info.nightscout.ui.dialogs.TreatmentDialog -import info.nightscout.ui.dialogs.WizardDialog import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign import java.util.Locale @@ -150,8 +142,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList @Inject lateinit var repository: AppRepository @Inject lateinit var glucoseStatusProvider: GlucoseStatusProvider @Inject lateinit var overviewData: OverviewData - @Inject lateinit var automationPlugin: AutomationPlugin - @Inject lateinit var bgQualityCheckPlugin: BgQualityCheckPlugin + @Inject lateinit var automation: Automation + @Inject lateinit var bgQualityCheck: BgQualityCheck @Inject lateinit var activityNames: ActivityNames private val disposable = CompositeDisposable() @@ -375,28 +367,28 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList R.id.treatment_button -> protectionCheck.queryProtection( activity, ProtectionCheck.Protection.BOLUS, - UIRunnable { if (isAdded) TreatmentDialog().show(childFragmentManager, "Overview") }) + UIRunnable { if (isAdded) activityNames.runTreatmentDialog(childFragmentManager) }) R.id.wizard_button -> protectionCheck.queryProtection( activity, ProtectionCheck.Protection.BOLUS, - UIRunnable { if (isAdded) WizardDialog().show(childFragmentManager, "Overview") }) + UIRunnable { if (isAdded) activityNames.runWizardDialog(childFragmentManager) }) R.id.insulin_button -> protectionCheck.queryProtection( activity, ProtectionCheck.Protection.BOLUS, - UIRunnable { if (isAdded) InsulinDialog().show(childFragmentManager, "Overview") }) + UIRunnable { if (isAdded) activityNames.runInsulinDialog(childFragmentManager) }) R.id.quick_wizard_button -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if (isAdded) onClickQuickWizard() }) R.id.carbs_button -> protectionCheck.queryProtection( activity, ProtectionCheck.Protection.BOLUS, - UIRunnable { if (isAdded) CarbsDialog().show(childFragmentManager, "Overview") }) + UIRunnable { if (isAdded) activityNames.runCarbsDialog(childFragmentManager) }) R.id.temp_target -> protectionCheck.queryProtection( activity, ProtectionCheck.Protection.BOLUS, - UIRunnable { if (isAdded) TempTargetDialog().show(childFragmentManager, "Overview") }) + UIRunnable { if (isAdded) activityNames.runTempTargetDialog(childFragmentManager) }) R.id.active_profile -> { activityNames.runProfileViewerDialog( @@ -419,7 +411,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList R.id.calibration_button -> { if (xdripPlugin.isEnabled()) { - CalibrationDialog().show(childFragmentManager, "CalibrationDialog") + activityNames.runCalibrationDialog(childFragmentManager) } else if (dexcomPlugin.isEnabled()) { try { dexcomMediator.findDexcomPackageName()?.let { @@ -431,7 +423,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } ?: ToastUtils.infoToast(activity, rh.gs(R.string.dexcom_app_not_installed)) } catch (e: ActivityNotFoundException) { - ToastUtils.infoToast(activity, rh.gs(R.string.g5appnotdetected)) + ToastUtils.infoToast(activity, rh.gs(R.string.dexcom_app_not_detected)) } } } @@ -461,9 +453,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList R.id.aps_mode -> { protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { - if (isAdded) LoopDialog().also { dialog -> - dialog.arguments = Bundle().also { it.putInt("showOkCancel", 1) } - }.show(childFragmentManager, "Overview") + if (isAdded) activityNames.runLoopDialog(childFragmentManager, 1) }) } } @@ -494,9 +484,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList R.id.aps_mode -> { activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { - LoopDialog().also { dialog -> - dialog.arguments = Bundle().also { it.putInt("showOkCancel", 0) } - }.show(childFragmentManager, "Overview") + activityNames.runLoopDialog(childFragmentManager, 0) }) } } @@ -508,7 +496,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList protectionCheck.queryProtection( activity, ProtectionCheck.Protection.BOLUS, - UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "ProfileSwitchDialog") }) + UIRunnable { activityNames.runProfileSwitchDialog(childFragmentManager) }) } } @@ -528,7 +516,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList val carbsAfterConstraints = constraintChecker.applyCarbsConstraints(Constraint(quickWizardEntry.carbs())).value() activity?.let { if (abs(wizard.insulinAfterConstraints - wizard.calculatedTotalInsulin) >= pump.pumpDescription.pumpType.determineCorrectBolusStepSize(wizard.insulinAfterConstraints) || carbsAfterConstraints != quickWizardEntry.carbs()) { - OKDialog.show(it, rh.gs(R.string.treatmentdeliveryerror), rh.gs(R.string.constraints_violation) + "\n" + rh.gs(R.string.changeyourinput)) + OKDialog.show(it, rh.gs(R.string.treatmentdeliveryerror), rh.gs(R.string.constraints_violation) + "\n" + rh.gs(R.string.change_your_input)) return } wizard.confirmAndExecute(it) @@ -571,7 +559,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList _binding ?: return@runOnUiThread if (showAcceptButton && pump.isInitialized() && !pump.isSuspended() && (loop as PluginBase).isEnabled()) { binding.buttonsLayout.acceptTempButton.visibility = View.VISIBLE - binding.buttonsLayout.acceptTempButton.text = "${rh.gs(R.string.setbasalquestion)}\n${lastRun!!.constraintsProcessed}" + binding.buttonsLayout.acceptTempButton.text = "${rh.gs(R.string.set_basal_question)}\n${lastRun!!.constraintsProcessed}" } else { binding.buttonsLayout.acceptTempButton.visibility = View.GONE } @@ -610,10 +598,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList // Automation buttons binding.buttonsLayout.userButtonsLayout.removeAllViews() - val events = automationPlugin.userEvents() + val events = automation.userEvents() if (!loop.isDisconnected && pump.isInitialized() && !pump.isSuspended() && profile != null) for (event in events) - if (event.isEnabled && event.trigger.shouldRun()) + if (event.isEnabled && event.canRun()) context?.let { context -> SingleClickButton(context, null, R.attr.customBtnStyle).also { it.setTextColor(rh.gac(context, R.attr.treatmentButton)) @@ -625,7 +613,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList it.text = event.title it.setOnClickListener { - OKDialog.showConfirmation(context, rh.gs(R.string.run_question, event.title), { handler.post { automationPlugin.processEvent(event) } }) + OKDialog.showConfirmation(context, rh.gs(R.string.run_question, event.title), { handler.post { automation.processEvent(event) } }) } binding.buttonsLayout.userButtonsLayout.addView(it) } @@ -644,7 +632,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { binding.infoLayout.apsMode.stateDescription = rh.gs(stringRes) } else { - binding.infoLayout.apsMode.contentDescription = rh.gs(R.string.apsmode_title) + " " + rh.gs(stringRes) + binding.infoLayout.apsMode.contentDescription = rh.gs(R.string.aps_mode_title) + " " + rh.gs(stringRes) } } @@ -830,13 +818,13 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList binding.infoLayout.timeAgo.contentDescription = dateUtil.minAgoLong(rh, lastBg?.timestamp) binding.infoLayout.timeAgoShort.text = "(" + dateUtil.minAgoShort(lastBg?.timestamp) + ")" - val qualityIcon = bgQualityCheckPlugin.icon() + val qualityIcon = bgQualityCheck.icon() if (qualityIcon != 0) { binding.infoLayout.bgQuality.visibility = View.VISIBLE binding.infoLayout.bgQuality.setImageResource(qualityIcon) - binding.infoLayout.bgQuality.contentDescription = rh.gs(R.string.a11y_bg_quality) + " " + bgQualityCheckPlugin.stateDescription() + binding.infoLayout.bgQuality.contentDescription = rh.gs(R.string.a11y_bg_quality) + " " + bgQualityCheck.stateDescription() binding.infoLayout.bgQuality.setOnClickListener { - context?.let { context -> OKDialog.show(context, rh.gs(R.string.data_status), bgQualityCheckPlugin.message) } + context?.let { context -> OKDialog.show(context, rh.gs(R.string.data_status), bgQualityCheck.message) } } } else { binding.infoLayout.bgQuality.visibility = View.GONE @@ -916,7 +904,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList insulinAge.visibility = isPatchPump.not().toVisibility() batteryLayout.visibility = (!isPatchPump || pump.pumpDescription.useHardwareLink).toVisibility() pbAge.visibility = (pump.pumpDescription.isBatteryReplaceable || pump.isBatteryChangeLoggingEnabled()).toVisibility() - val useBatteryLevel = (pump.model() == PumpType.OMNIPOD_EROS && pump is OmnipodErosPumpPlugin) + val useBatteryLevel = (pump.model() == PumpType.OMNIPOD_EROS) || (pump.model() != PumpType.ACCU_CHEK_COMBO && pump.model() != PumpType.OMNIPOD_DASH) batteryLevel.visibility = useBatteryLevel.toVisibility() statusLights.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility() @@ -1118,7 +1106,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList val request = loop.lastRun?.request val isfMgdl = profile?.getIsfMgdl() val variableSens = - if (config.APS && request is info.nightscout.plugins.aps.openAPSSMB.DetermineBasalResultSMB) request.variableSens ?: 0.0 + if (config.APS && request is VariableSensitivityResult) request.variableSens ?: 0.0 else if (config.NSCLIENT) JsonHelper.safeGetDouble(processedDeviceStatusData.getAPSResult(injector).json, "variable_sens") else 0.0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewMenus.kt similarity index 94% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt rename to plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewMenus.kt index 9c4858872e..1f0ef27102 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewMenus.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.overview +package info.nightscout.plugins.general.overview import android.content.Context import android.text.SpannableString @@ -11,10 +11,10 @@ import androidx.annotation.AttrRes import androidx.annotation.StringRes import androidx.appcompat.widget.PopupMenu import com.google.gson.Gson -import info.nightscout.androidaps.R import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.interfaces.Config import info.nightscout.interfaces.aps.Loop +import info.nightscout.plugins.R import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventRefreshOverview import info.nightscout.rx.events.EventScale @@ -39,14 +39,14 @@ class OverviewMenus @Inject constructor( PRE(R.string.overview_show_predictions, R.attr.predictionColor, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.prediction_shortname), TREAT(R.string.overview_show_treatments, R.attr.cobColor, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.treatments_shortname), BAS(R.string.overview_show_basals, R.attr.basal, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.basal_shortname), - ABS(R.string.overview_show_absinsulin, R.attr.iobColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.abs_insulin_shortname), + ABS(R.string.overview_show_abs_insulin, R.attr.iobColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.abs_insulin_shortname), IOB(R.string.overview_show_iob, R.attr.iobColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.iob), COB(R.string.overview_show_cob, R.attr.cobColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.cob), DEV(R.string.overview_show_deviations, R.attr.bgiColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.deviation_shortname), BGI(R.string.overview_show_bgi, R.attr.bgiColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.bgi_shortname), SEN(R.string.overview_show_sensitivity, R.attr.ratioColor, R.attr.menuTextColorInverse, primary = false, secondary = true, shortnameId = R.string.sensitivity_shortname), ACT(R.string.overview_show_activity, R.attr.activityColor, R.attr.menuTextColor, primary = true, secondary = false, shortnameId = R.string.activity_shortname), - DEVSLOPE(R.string.overview_show_deviationslope, R.attr.devSlopePosColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.devslope_shortname) + DEVSLOPE(R.string.overview_show_deviation_slope, R.attr.devSlopePosColor, R.attr.menuTextColor, primary = false, secondary = true, shortnameId = R.string.devslope_shortname) } companion object { @@ -72,13 +72,13 @@ class OverviewMenus @Inject constructor( @Synchronized private fun storeGraphConfig() { val sts = Gson().toJson(_setting) - sp.putString(R.string.key_graphconfig, sts) + sp.putString(R.string.key_graph_config, sts) aapsLogger.debug(sts) } @Synchronized fun loadGraphConfig() { - val sts = sp.getString(R.string.key_graphconfig, "") + val sts = sp.getString(R.string.key_graph_config, "") if (sts.isNotEmpty()) { _setting = Gson().fromJson(sts, Array>::class.java).toMutableList() // reset when new CharType added diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewPlugin.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt rename to plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewPlugin.kt index 971152a286..9326b2edfa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewPlugin.kt @@ -1,18 +1,16 @@ -package info.nightscout.androidaps.plugins.general.overview +package info.nightscout.plugins.general.overview import android.content.Context import androidx.annotation.StringRes import androidx.preference.PreferenceFragmentCompat import androidx.preference.SwitchPreference import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R import info.nightscout.androidaps.extensions.putDouble import info.nightscout.androidaps.extensions.putInt import info.nightscout.androidaps.extensions.putString import info.nightscout.androidaps.extensions.storeDouble import info.nightscout.androidaps.extensions.storeInt import info.nightscout.androidaps.extensions.storeString -import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewCalcProgress import info.nightscout.core.events.EventNewNotification import info.nightscout.core.graph.OverviewData import info.nightscout.core.ui.dialogs.OKDialog @@ -22,6 +20,8 @@ import info.nightscout.interfaces.Overview import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginType +import info.nightscout.plugins.R +import info.nightscout.plugins.general.overview.events.EventUpdateOverviewCalcProgress import info.nightscout.plugins.general.overview.notifications.NotificationStore import info.nightscout.plugins.general.overview.notifications.NotificationWithAction import info.nightscout.plugins.general.overview.notifications.events.EventUpdateOverviewNotification diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/activities/QuickWizardListActivity.kt similarity index 95% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt rename to plugins/main/src/main/java/info/nightscout/plugins/general/overview/activities/QuickWizardListActivity.kt index dbc68aa4f0..f84ff6f44d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/activities/QuickWizardListActivity.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.overview.activities +package info.nightscout.plugins.general.overview.activities import android.annotation.SuppressLint import android.os.Bundle @@ -14,11 +14,6 @@ import androidx.fragment.app.FragmentManager import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import info.nightscout.androidaps.R -import info.nightscout.androidaps.databinding.OverviewQuickwizardlistActivityBinding -import info.nightscout.androidaps.databinding.OverviewQuickwizardlistItemBinding -import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog -import info.nightscout.androidaps.plugins.general.overview.events.EventQuickWizardChange import info.nightscout.core.activities.DaggerAppCompatActivityWithResult import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.utils.ActionModeHelper @@ -28,6 +23,11 @@ import info.nightscout.core.wizard.QuickWizardEntry import info.nightscout.interfaces.dragHelpers.ItemTouchHelperAdapter import info.nightscout.interfaces.dragHelpers.OnStartDragListener import info.nightscout.interfaces.dragHelpers.SimpleItemTouchHelperCallback +import info.nightscout.plugins.R +import info.nightscout.plugins.databinding.OverviewQuickwizardlistActivityBinding +import info.nightscout.plugins.databinding.OverviewQuickwizardlistItemBinding +import info.nightscout.plugins.general.overview.dialogs.EditQuickWizardDialog +import info.nightscout.plugins.general.overview.events.EventQuickWizardChange import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus import info.nightscout.shared.extensions.toVisibility diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/EditQuickWizardDialog.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/dialogs/EditQuickWizardDialog.kt similarity index 96% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/EditQuickWizardDialog.kt rename to plugins/main/src/main/java/info/nightscout/plugins/general/overview/dialogs/EditQuickWizardDialog.kt index 7ed67d1327..6df74ef1f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/EditQuickWizardDialog.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/dialogs/EditQuickWizardDialog.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.overview.dialogs +package info.nightscout.plugins.general.overview.dialogs import android.os.Bundle import android.text.format.DateFormat @@ -10,14 +10,14 @@ import android.view.WindowManager import com.google.android.material.timepicker.MaterialTimePicker import com.google.android.material.timepicker.TimeFormat import dagger.android.support.DaggerDialogFragment -import info.nightscout.androidaps.R -import info.nightscout.androidaps.databinding.OverviewEditquickwizardDialogBinding -import info.nightscout.androidaps.plugins.general.overview.events.EventQuickWizardChange import info.nightscout.androidaps.utils.extensions.selectedItemPosition import info.nightscout.androidaps.utils.extensions.setEnableForChildren import info.nightscout.androidaps.utils.extensions.setSelection import info.nightscout.core.wizard.QuickWizard import info.nightscout.core.wizard.QuickWizardEntry +import info.nightscout.plugins.R +import info.nightscout.plugins.databinding.OverviewEditquickwizardDialogBinding +import info.nightscout.plugins.general.overview.events.EventQuickWizardChange import info.nightscout.rx.bus.RxBus import info.nightscout.rx.logging.AAPSLogger import info.nightscout.shared.SafeParse @@ -36,8 +36,8 @@ class EditQuickWizardDialog : DaggerDialogFragment(), View.OnClickListener { @Inject lateinit var sp: SP var position = -1 - var fromSeconds: Int = 0 - var toSeconds: Int = 0 + private var fromSeconds: Int = 0 + private var toSeconds: Int = 0 private var _binding: OverviewEditquickwizardDialogBinding? = null diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventQuickWizardChange.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventQuickWizardChange.kt similarity index 54% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventQuickWizardChange.kt rename to plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventQuickWizardChange.kt index b02bf909aa..543da400e4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventQuickWizardChange.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventQuickWizardChange.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.overview.events +package info.nightscout.plugins.general.overview.events import info.nightscout.rx.events.Event diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventUpdateOverviewCalcProgress.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventUpdateOverviewCalcProgress.kt similarity index 61% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventUpdateOverviewCalcProgress.kt rename to plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventUpdateOverviewCalcProgress.kt index ac931599e7..cb4aabd394 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventUpdateOverviewCalcProgress.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventUpdateOverviewCalcProgress.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.overview.events +package info.nightscout.plugins.general.overview.events import info.nightscout.rx.events.Event diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventUpdateOverviewGraph.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventUpdateOverviewGraph.kt similarity index 59% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventUpdateOverviewGraph.kt rename to plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventUpdateOverviewGraph.kt index 12135b93a3..37bcf5d7ea 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventUpdateOverviewGraph.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventUpdateOverviewGraph.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.overview.events +package info.nightscout.plugins.general.overview.events import info.nightscout.rx.events.Event diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventUpdateOverviewIobCob.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventUpdateOverviewIobCob.kt similarity index 59% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventUpdateOverviewIobCob.kt rename to plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventUpdateOverviewIobCob.kt index 7029768a69..dd0a2ff82e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventUpdateOverviewIobCob.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventUpdateOverviewIobCob.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.overview.events +package info.nightscout.plugins.general.overview.events import info.nightscout.rx.events.Event diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventUpdateOverviewSensitivity.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventUpdateOverviewSensitivity.kt similarity index 61% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventUpdateOverviewSensitivity.kt rename to plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventUpdateOverviewSensitivity.kt index ef63ee8e4a..d9490a803a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventUpdateOverviewSensitivity.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/events/EventUpdateOverviewSensitivity.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.overview.events +package info.nightscout.plugins.general.overview.events import info.nightscout.rx.events.Event diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/graphData/GraphData.kt similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt rename to plugins/main/src/main/java/info/nightscout/plugins/general/overview/graphData/GraphData.kt index b5cf3a0695..e175e42ca7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/graphData/GraphData.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.overview.graphData +package info.nightscout.plugins.general.overview.graphData import android.content.Context import android.graphics.DashPathEffect @@ -8,7 +8,6 @@ import com.jjoe64.graphview.series.DataPoint import com.jjoe64.graphview.series.LineGraphSeries import com.jjoe64.graphview.series.Series import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R import info.nightscout.core.graph.OverviewData import info.nightscout.core.graph.data.BolusDataPoint import info.nightscout.core.graph.data.EffectiveProfileSwitchDataPoint @@ -19,6 +18,7 @@ import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.profile.DefaultValueHelper import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.utils.Round +import info.nightscout.plugins.R import info.nightscout.rx.logging.AAPSLogger import info.nightscout.shared.interfaces.ResourceHelper import javax.inject.Inject diff --git a/app/src/main/res/drawable/ic_arrow_drop_up_white_24dp.xml b/plugins/main/src/main/res/drawable/ic_arrow_drop_up_white_24dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_arrow_drop_up_white_24dp.xml rename to plugins/main/src/main/res/drawable/ic_arrow_drop_up_white_24dp.xml diff --git a/app/src/main/res/drawable/ic_byoda.xml b/plugins/main/src/main/res/drawable/ic_byoda.xml similarity index 100% rename from app/src/main/res/drawable/ic_byoda.xml rename to plugins/main/src/main/res/drawable/ic_byoda.xml diff --git a/app/src/main/res/drawable/ic_loop_superbolus.xml b/plugins/main/src/main/res/drawable/ic_loop_superbolus.xml similarity index 100% rename from app/src/main/res/drawable/ic_loop_superbolus.xml rename to plugins/main/src/main/res/drawable/ic_loop_superbolus.xml diff --git a/plugins/main/src/main/res/layout/overview_buttons_layout.xml b/plugins/main/src/main/res/layout/overview_buttons_layout.xml index dd0344ad97..2006e2d11c 100644 --- a/plugins/main/src/main/res/layout/overview_buttons_layout.xml +++ b/plugins/main/src/main/res/layout/overview_buttons_layout.xml @@ -13,7 +13,7 @@ android:layout_height="wrap_content" android:paddingStart="5dp" android:paddingEnd="5dp" - android:text="@string/setbasalquestion" + android:text="@string/set_basal_question" android:textColor="?attr/acceptTempButtonColor" android:visibility="gone" /> diff --git a/app/src/main/res/layout/overview_editquickwizard_dialog.xml b/plugins/main/src/main/res/layout/overview_editquickwizard_dialog.xml similarity index 92% rename from app/src/main/res/layout/overview_editquickwizard_dialog.xml rename to plugins/main/src/main/res/layout/overview_editquickwizard_dialog.xml index 19e9140002..97694909dd 100644 --- a/app/src/main/res/layout/overview_editquickwizard_dialog.xml +++ b/plugins/main/src/main/res/layout/overview_editquickwizard_dialog.xml @@ -4,7 +4,7 @@ style="@style/StyleDialog" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".plugins.general.overview.dialogs.EditQuickWizardDialog"> + tools:context="info.nightscout.plugins.general.overview.dialogs.EditQuickWizardDialog"> @@ -40,7 +40,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:labelFor="@+id/button_edit" - android:text="@string/overview_editquickwizard_buttontext" + android:text="@string/overview_edit_quickwizard_button_text" android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> + android:text="@string/positive_only" /> + android:text="@string/negative_only" /> @@ -249,7 +249,7 @@ + android:text="@string/positive_only" /> + android:text="@string/negative_only" /> + android:contentDescription="@string/aps_mode_title" /> + tools:context="info.nightscout.plugins.general.overview.activities.QuickWizardListActivity"> diff --git a/app/src/main/res/layout/overview_quickwizardlist_item.xml b/plugins/main/src/main/res/layout/overview_quickwizardlist_item.xml similarity index 98% rename from app/src/main/res/layout/overview_quickwizardlist_item.xml rename to plugins/main/src/main/res/layout/overview_quickwizardlist_item.xml index 3c4c4f70ec..022d61e21b 100644 --- a/app/src/main/res/layout/overview_quickwizardlist_item.xml +++ b/plugins/main/src/main/res/layout/overview_quickwizardlist_item.xml @@ -108,7 +108,7 @@ android:layout_gravity="top" android:paddingStart="10dp" android:paddingEnd="5dp" - android:text="@string/overview_editquickwizard_valid" + android:text="@string/overview_edit_quickwizard_valid" android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> Treatments safety + show_calibration_button + show_cgm_button + show_carbs_button + show_wizard_button + show_insulin_button + show_treatment_button statuslights_copy_ns statuslights_overview_advanced + keep_screen_on + short_tabtitles Copy NS settings (if exists)? show_statuslights @@ -296,10 +304,112 @@ blood glucose quality blood glucose outdated - APS Mode - Accept new temp basal: + APS Mode + Accept new temp basal: CGM QuickWizard + only on watch + only on phone + Overview + HOME + Displays the current state of your loop and buttons for most common actions + COB calculation + Temporary target calculation + Percentage calculation + Buttons + Sends a calibration to xDrip+ or open BYODA calibration dialog + Opens xDrip+ or BYODA, back buttons returns to AAPS + Dexcom app is not installed. + Please update your Dexcom app to supported version + Could not launch CGM application. Make sure it is installed. + Not available + Constraints violation + Change your input! + OpenAPS + Uploader + BG data status + QuickWizard settings + Button text: + Carbs: + Valid: + Add + Edit + Show entry on device: + BG calculation + Bolus IOB calculation + Basal IOB calculation + Trend calculation + Superbolus calculation + Percentage + All + Phone + Watch + Positive only + Negative only + Application default + drag and drop handle + Keep screen on + Prevent Android to turn screen off. It will consume lot of energy when not plugged to power outlet. + Treatments + Number of carbs to add when button is pressed + Amount of insulin to add when button is pressed + First insulin increment + Second insulin increment + Third insulin increment + First carbs increment + Second carbs increment + Third carbs increment + CGM + Default Temp-Targets + eatingsoon duration + eatingsoon target + activity duration + activity target + hypo duration + hypo target + Fill/Prime standard insulin amounts + Button 1 + Button 2 + Button 3 + Range for Visualization + High and low mark for the charts in Overview and Smartwatch + LOW mark + HIGH mark + Shorten tab titles + Show notes field in treatment dialogs + Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm. + Enable bolus advisor + Use reminder to start eating later instead of wizard result during high glycemia ("pre-bolus") + Enable superbolus in wizard + Enable superbolus functionality in wizard. Do not enable until you learn what it really does. IT MAY CAUSE INSULIN OVERDOSE IF USED BLINDLY! + Enable bolus reminder + Use reminder to bolus later with wizard ("post-bolus") + + + graphconfig + + Predictions + Treatments + Deviation slope + Activity + Blood Glucose Impact + Sensitivity + Deviations + Carbs On Board + Insulin On Board + Basals + Absolute insulin + PRED + BAS + DEV + ACT + -BGI + ABS + DEVSLOPE + TREAT + SENS + Graph scale + Graph ns_client_autoscroll diff --git a/plugins/main/src/main/res/xml/pref_loop.xml b/plugins/main/src/main/res/xml/pref_loop.xml index 84d4454a1c..3022f68920 100644 --- a/plugins/main/src/main/res/xml/pref_loop.xml +++ b/plugins/main/src/main/res/xml/pref_loop.xml @@ -13,7 +13,7 @@ android:entries="@array/aps_modeArray" android:entryValues="@array/aps_modeValues" android:key="@string/key_aps_mode" - android:title="@string/apsmode_title" /> + android:title="@string/aps_mode_title" /> + android:title="@string/quickwizard_settings"> diff --git a/plugins/support/src/main/java/info/nightscout/plugins/constraints/bgQualityCheck/BgQualityCheckPlugin.kt b/plugins/support/src/main/java/info/nightscout/plugins/constraints/bgQualityCheck/BgQualityCheckPlugin.kt index 519108378a..85da3a2dfa 100644 --- a/plugins/support/src/main/java/info/nightscout/plugins/constraints/bgQualityCheck/BgQualityCheckPlugin.kt +++ b/plugins/support/src/main/java/info/nightscout/plugins/constraints/bgQualityCheck/BgQualityCheckPlugin.kt @@ -1,7 +1,9 @@ package info.nightscout.plugins.constraints.bgQualityCheck +import androidx.annotation.DrawableRes import dagger.android.HasAndroidInjector import info.nightscout.core.utils.fabric.FabricPrivacy +import info.nightscout.interfaces.bgQualityCheck.BgQualityCheck import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Constraints import info.nightscout.interfaces.iob.IobCobCalculator @@ -43,7 +45,7 @@ class BgQualityCheckPlugin @Inject constructor( .showInList(false) .pluginName(R.string.bg_quality), aapsLogger, rh, injector -), Constraints { +), Constraints, BgQualityCheck { private var disposable: CompositeDisposable = CompositeDisposable() @@ -68,7 +70,7 @@ class BgQualityCheckPlugin @Inject constructor( } var state: State = State.UNKNOWN - var message: String = "" + override var message: String = "" // Fallback to LGS if BG values are doubled override fun applyMaxIOBConstraints(maxIob: Constraint): Constraint = @@ -100,7 +102,7 @@ class BgQualityCheckPlugin @Inject constructor( } } - fun icon(): Int = + @DrawableRes override fun icon(): Int = when (state) { State.UNKNOWN -> 0 State.FIVE_MIN_DATA -> 0 @@ -108,7 +110,7 @@ class BgQualityCheckPlugin @Inject constructor( State.DOUBLED -> R.drawable.ic_baseline_warning_24_red } - fun stateDescription(): String = + override fun stateDescription(): String = when (state) { State.RECALCULATED -> rh.gs(R.string.a11y_bg_quality_recalculated) State.DOUBLED -> rh.gs(R.string.a11y_bg_quality_doubles) diff --git a/plugins/support/src/main/java/info/nightscout/plugins/support/di/PluginsSupportModule.kt b/plugins/support/src/main/java/info/nightscout/plugins/support/di/PluginsSupportModule.kt index 72371e4afd..0708f172b3 100644 --- a/plugins/support/src/main/java/info/nightscout/plugins/support/di/PluginsSupportModule.kt +++ b/plugins/support/src/main/java/info/nightscout/plugins/support/di/PluginsSupportModule.kt @@ -2,7 +2,9 @@ package info.nightscout.plugins.support.di import dagger.Binds import dagger.Module +import info.nightscout.interfaces.bgQualityCheck.BgQualityCheck import info.nightscout.interfaces.versionChecker.VersionCheckerUtils +import info.nightscout.plugins.constraints.bgQualityCheck.BgQualityCheckPlugin import info.nightscout.plugins.constraints.versionChecker.VersionCheckerUtilsImpl @Module( @@ -17,5 +19,6 @@ abstract class PluginsSupportModule { interface Bindings { @Binds fun bindProcessedDeviceStatusData(versionCheckerUtils: VersionCheckerUtilsImpl): VersionCheckerUtils + @Binds fun bindBgQualityCheck(bgQualityCheck: BgQualityCheckPlugin): BgQualityCheck } } \ No newline at end of file diff --git a/plugins/support/src/test/java/info/nightscout/plugins/constraints/bgQualityCheck/BgQualityCheckPluginTest.kt b/plugins/support/src/test/java/info/nightscout/plugins/constraints/bgQualityCheck/BgQualityCheckPluginTest.kt index 59a7835a50..f55172d99e 100644 --- a/plugins/support/src/test/java/info/nightscout/plugins/constraints/bgQualityCheck/BgQualityCheckPluginTest.kt +++ b/plugins/support/src/test/java/info/nightscout/plugins/constraints/bgQualityCheck/BgQualityCheckPluginTest.kt @@ -16,7 +16,9 @@ import info.nightscout.shared.utils.T import org.junit.Assert import org.junit.Before import org.junit.Test +import org.mockito.ArgumentMatchers.any import org.mockito.Mock +import org.mockito.Mockito.anyInt import org.mockito.Mockito.`when` class BgQualityCheckPluginTest : TestBase() { @@ -46,6 +48,8 @@ class BgQualityCheckPluginTest : TestBase() { dateUtil ) `when`(iobCobCalculator.ads).thenReturn(autosensDataStore) + `when`(rh.gs(anyInt())).thenReturn("") + `when`(rh.gs(anyInt(), any(), any())).thenReturn("") } @Test diff --git a/ui/src/main/res/values/strings.xml b/ui/src/main/res/values/strings.xml index fcc3db5ef8..9e5ae8031c 100644 --- a/ui/src/main/res/values/strings.xml +++ b/ui/src/main/res/values/strings.xml @@ -41,15 +41,10 @@ %1$s ISF: %2$.1f %1$.1fg IC: %2$.1f %1$.0fg IC: %2$.1f - Superbolus Total Please make sure the amount matches the specification of your infusion set! - Fill/Prime standard insulin amounts - Button 1 - Button 2 - Button 3 Record pump site change Record insulin cartridge change