From ccb42caa609ba25e7a619bee00480e7376e695d1 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 11 Nov 2022 10:46:41 +0100 Subject: [PATCH] TreatmentDialog -> ui --- .../info/nightscout/androidaps/MainApp.kt | 4 +- .../androidaps/di/FragmentsModule.kt | 2 - .../androidaps/dialogs/InsulinDialog.kt | 2 - .../general/overview/OverviewFragment.kt | 8 +-- .../androidaps/utils/wizard/BolusWizard.kt | 4 +- app/src/main/res/menu/menu_main.xml | 2 +- app/src/main/res/xml/pref_overview.xml | 4 +- .../info}/activityMonitor/ActivityMonitor.kt | 11 ++-- .../ui/activities/ProfileHelperActivity.kt | 30 +++++------ .../nightscout/ui/activities/StatsActivity.kt | 4 +- .../java/info/nightscout/ui/di/UiModule.kt | 2 + .../info/nightscout/ui/dialogs/FillDialog.kt | 4 +- .../nightscout/ui/dialogs/InsulinDialog.kt | 4 +- .../nightscout/ui}/dialogs/TreatmentDialog.kt | 51 ++++++++++--------- .../res/layout/activity_profilehelper.xml | 8 +-- .../src/main/res/layout/dialog_treatment.xml | 0 ui/src/main/res/values/strings.xml | 32 ++++++------ 17 files changed, 87 insertions(+), 85 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt rename {ui/src/main/java/info/nightscout/ui => app/src/test/java/info}/activityMonitor/ActivityMonitor.kt (99%) rename {app/src/main/java/info/nightscout/androidaps => ui/src/main/java/info/nightscout/ui}/dialogs/TreatmentDialog.kt (85%) rename {app => ui}/src/main/res/layout/dialog_treatment.xml (100%) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.kt b/app/src/main/java/info/nightscout/androidaps/MainApp.kt index 0f17bfecad..c785ddde68 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.kt @@ -15,6 +15,7 @@ import androidx.work.PeriodicWorkRequest import androidx.work.WorkManager import dagger.android.AndroidInjector import dagger.android.DaggerApplication +import info.activityMonitor.ActivityMonitor import info.nightscout.androidaps.db.CompatDBHelper import info.nightscout.androidaps.di.DaggerAppComponent import info.nightscout.androidaps.di.StaticInjector @@ -47,7 +48,6 @@ import info.nightscout.rx.logging.LTag import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil -import info.nightscout.ui.activityMonitor.ActivityMonitor import info.nightscout.ui.widget.Widget import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.exceptions.UndeliverableException @@ -65,7 +65,7 @@ class MainApp : DaggerApplication() { @Inject lateinit var pluginStore: PluginStore @Inject lateinit var aapsLogger: AAPSLogger - @Inject lateinit var activityMonitor: ActivityMonitor + @Inject lateinit var activityMonitor: info.activityMonitor.ActivityMonitor @Inject lateinit var versionCheckersUtils: VersionCheckerUtils @Inject lateinit var sp: SP @Inject lateinit var config: Config 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 9a2a9dda6e..288b6bdd19 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/FragmentsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/FragmentsModule.kt @@ -8,7 +8,6 @@ import info.nightscout.androidaps.dialogs.NtpProgressDialog import info.nightscout.androidaps.dialogs.ProfileSwitchDialog import info.nightscout.androidaps.dialogs.TempBasalDialog import info.nightscout.androidaps.dialogs.TempTargetDialog -import info.nightscout.androidaps.dialogs.TreatmentDialog import info.nightscout.androidaps.dialogs.WizardDialog import info.nightscout.androidaps.plugins.aps.OpenAPSFragment import info.nightscout.androidaps.plugins.aps.loop.LoopFragment @@ -44,7 +43,6 @@ abstract class FragmentsModule { @ContributesAndroidInjector abstract fun contributesProfileSwitchDialog(): ProfileSwitchDialog @ContributesAndroidInjector abstract fun contributesTempBasalDialog(): TempBasalDialog @ContributesAndroidInjector abstract fun contributesTempTargetDialog(): TempTargetDialog - @ContributesAndroidInjector abstract fun contributesTreatmentDialog(): TreatmentDialog @ContributesAndroidInjector abstract fun contributesWizardDialog(): WizardDialog @ContributesAndroidInjector abstract fun contributesNtpProgressDialog(): NtpProgressDialog @ContributesAndroidInjector abstract fun contributesPasswordCheck(): PasswordCheck diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt deleted file mode 100644 index 2e4bef4f6d..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ /dev/null @@ -1,2 +0,0 @@ -package info.nightscout.androidaps.dialogs - diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index c99e239d16..f6cdbf8874 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -30,11 +30,9 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.databinding.OverviewFragmentBinding -import info.nightscout.ui.dialogs.InsulinDialog import info.nightscout.androidaps.dialogs.LoopDialog import info.nightscout.androidaps.dialogs.ProfileSwitchDialog import info.nightscout.androidaps.dialogs.TempTargetDialog -import info.nightscout.androidaps.dialogs.TreatmentDialog import info.nightscout.androidaps.dialogs.WizardDialog import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged import info.nightscout.androidaps.events.EventNewBG @@ -60,8 +58,6 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOve 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.plugins.source.DexcomPlugin -import info.nightscout.plugins.source.XdripPlugin import info.nightscout.androidaps.skins.SkinProvider import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.ToastUtils @@ -92,6 +88,8 @@ import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.plugins.constraints.bgQualityCheck.BgQualityCheckPlugin import info.nightscout.plugins.general.overview.notifications.NotificationStore import info.nightscout.plugins.general.overview.notifications.events.EventUpdateOverviewNotification +import info.nightscout.plugins.source.DexcomPlugin +import info.nightscout.plugins.source.XdripPlugin import info.nightscout.plugins.sync.nsclient.data.NSSettingsStatus import info.nightscout.plugins.sync.nsclient.data.ProcessedDeviceStatusData import info.nightscout.rx.AapsSchedulers @@ -112,6 +110,8 @@ 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.TreatmentDialog import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign import java.util.Locale diff --git a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt index 68d20dcaa9..78c192a29b 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt @@ -348,9 +348,9 @@ class BolusWizard @Inject constructor( actions.add(rh.gs(R.string.slowabsorptiondetected, rh.gac(context, R.attr.cobAlertColor), (absorptionRate * 100).toInt())) } if (abs(insulinAfterConstraints - calculatedTotalInsulin) > activePlugin.activePump.pumpDescription.pumpType.determineCorrectBolusStepSize(insulinAfterConstraints)) - actions.add(rh.gs(R.string.bolusconstraintappliedwarn, calculatedTotalInsulin, insulinAfterConstraints).formatColor(context, rh, R.attr.warningColor)) + actions.add(rh.gs(R.string.bolus_constraint_applied_warn, calculatedTotalInsulin, insulinAfterConstraints).formatColor(context, rh, R.attr.warningColor)) if (config.NSCLIENT && insulinAfterConstraints > 0) - actions.add(rh.gs(R.string.bolusrecordedonly).formatColor(context, rh, R.attr.warningColor)) + actions.add(rh.gs(R.string.bolus_recorded_only).formatColor(context, rh, R.attr.warningColor)) if (useAlarm && !advisor && carbs > 0 && carbTime > 0) actions.add(rh.gs(R.string.alarminxmin, carbTime).formatColor(context, rh, R.attr.infoColor)) if (advisor) diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 1cd9f44799..df1e452145 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -43,7 +43,7 @@ android:id="@+id/nav_defaultprofile" android:orderInCategory="1" app:showAsAction="never" - android:title="@string/nav_profilehelper" /> + android:title="@string/nav_profile_helper" /> + android:key="@string/fill_bolus_title" + android:title="@string/fill_bolus_title"> when (binding.profileType.text.toString()) { - rh.gs(R.string.motoldefaultprofile) -> switchTab(tabSelected, ProfileType.MOTOL_DEFAULT) - rh.gs(R.string.dpvdefaultprofile) -> switchTab(tabSelected, ProfileType.DPV_DEFAULT) - rh.gs(R.string.currentprofile) -> switchTab(tabSelected, ProfileType.CURRENT) - rh.gs(R.string.availableprofile) -> switchTab(tabSelected, ProfileType.AVAILABLE_PROFILE) + rh.gs(R.string.motol_default_profile) -> switchTab(tabSelected, ProfileType.MOTOL_DEFAULT) + rh.gs(R.string.dpv_default_profile) -> switchTab(tabSelected, ProfileType.DPV_DEFAULT) + rh.gs(R.string.current_profile) -> switchTab(tabSelected, ProfileType.CURRENT) + rh.gs(R.string.available_profile) -> switchTab(tabSelected, ProfileType.AVAILABLE_PROFILE) rh.gs(R.string.careportal_profileswitch) -> switchTab(tabSelected, ProfileType.PROFILE_SWITCH) } } @@ -205,7 +205,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { return@setOnClickListener } if ((pctUsed[i] < 32 || pctUsed[i] > 37)) { - ToastUtils.warnToast(this, R.string.invalidpct) + ToastUtils.warnToast(this, R.string.invalid_pct) return@setOnClickListener } } @@ -259,8 +259,8 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { private fun getProfileName(age: Double, tdd: Double, weight: Double, basalSumPct: Double, tab: Int): String = when (typeSelected[tab]) { - ProfileType.MOTOL_DEFAULT -> if (tdd > 0) rh.gs(R.string.formatwithtdd, age, tdd) else rh.gs(R.string.formatwithweight, age, weight) - ProfileType.DPV_DEFAULT -> rh.gs(R.string.formatwittddandpct, age, tdd, (basalSumPct * 100).toInt()) + ProfileType.MOTOL_DEFAULT -> if (tdd > 0) rh.gs(R.string.format_with_tdd, age, tdd) else rh.gs(R.string.format_with_weight, age, weight) + ProfileType.DPV_DEFAULT -> rh.gs(R.string.format_with_tdd_and_pct, age, tdd, (basalSumPct * 100).toInt()) ProfileType.CURRENT -> profileFunction.getProfileName() ProfileType.AVAILABLE_PROFILE -> profileList[profileUsed[tab]].toString() ProfileType.PROFILE_SWITCH -> profileSwitch[profileSwitchUsed[tab]].originalCustomizedName @@ -283,10 +283,10 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { // Show new content binding.profileType.setText( when (typeSelected[tabSelected]) { - ProfileType.MOTOL_DEFAULT -> rh.gs(R.string.motoldefaultprofile) - ProfileType.DPV_DEFAULT -> rh.gs(R.string.dpvdefaultprofile) - ProfileType.CURRENT -> rh.gs(R.string.currentprofile) - ProfileType.AVAILABLE_PROFILE -> rh.gs(R.string.availableprofile) + ProfileType.MOTOL_DEFAULT -> rh.gs(R.string.motol_default_profile) + ProfileType.DPV_DEFAULT -> rh.gs(R.string.dpv_default_profile) + ProfileType.CURRENT -> rh.gs(R.string.current_profile) + ProfileType.AVAILABLE_PROFILE -> rh.gs(R.string.available_profile) ProfileType.PROFILE_SWITCH -> rh.gs(R.string.careportal_profileswitch) }, false diff --git a/ui/src/main/java/info/nightscout/ui/activities/StatsActivity.kt b/ui/src/main/java/info/nightscout/ui/activities/StatsActivity.kt index 2b1c996454..2c60341dac 100644 --- a/ui/src/main/java/info/nightscout/ui/activities/StatsActivity.kt +++ b/ui/src/main/java/info/nightscout/ui/activities/StatsActivity.kt @@ -3,6 +3,7 @@ package info.nightscout.ui.activities import android.annotation.SuppressLint import android.os.Bundle import android.widget.TextView +import info.activityMonitor.ActivityMonitor import info.nightscout.androidaps.activities.NoSplashAppCompatActivity import info.nightscout.androidaps.interfaces.stats.DexcomTirCalculator import info.nightscout.androidaps.interfaces.stats.TddCalculator @@ -15,7 +16,6 @@ import info.nightscout.database.entities.UserEntry.Sources import info.nightscout.rx.AapsSchedulers import info.nightscout.ui.R import info.nightscout.ui.databinding.ActivityStatsBinding -import info.nightscout.ui.activityMonitor.ActivityMonitor import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign @@ -26,7 +26,7 @@ class StatsActivity : NoSplashAppCompatActivity() { @Inject lateinit var tddCalculator: TddCalculator @Inject lateinit var tirCalculator: TirCalculator @Inject lateinit var dexcomTirCalculator: DexcomTirCalculator - @Inject lateinit var activityMonitor: ActivityMonitor + @Inject lateinit var activityMonitor: info.activityMonitor.ActivityMonitor @Inject lateinit var uel: UserEntryLogger @Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var fabricPrivacy: FabricPrivacy diff --git a/ui/src/main/java/info/nightscout/ui/di/UiModule.kt b/ui/src/main/java/info/nightscout/ui/di/UiModule.kt index 0968c35b24..c7ef352a37 100644 --- a/ui/src/main/java/info/nightscout/ui/di/UiModule.kt +++ b/ui/src/main/java/info/nightscout/ui/di/UiModule.kt @@ -23,6 +23,7 @@ import info.nightscout.ui.dialogs.ExtendedBolusDialog import info.nightscout.ui.dialogs.FillDialog import info.nightscout.ui.dialogs.InsulinDialog import info.nightscout.ui.dialogs.ProfileViewerDialog +import info.nightscout.ui.dialogs.TreatmentDialog import info.nightscout.ui.dialogs.WizardInfoDialog @Module @@ -37,6 +38,7 @@ abstract class UiModule { @ContributesAndroidInjector abstract fun contributesExtendedBolusDialog(): ExtendedBolusDialog @ContributesAndroidInjector abstract fun contributesFillDialog(): FillDialog @ContributesAndroidInjector abstract fun contributesInsulinDialog(): InsulinDialog + @ContributesAndroidInjector abstract fun contributesTreatmentDialog(): TreatmentDialog @ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity @ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity diff --git a/ui/src/main/java/info/nightscout/ui/dialogs/FillDialog.kt b/ui/src/main/java/info/nightscout/ui/dialogs/FillDialog.kt index 2f5d388375..9d99747f57 100644 --- a/ui/src/main/java/info/nightscout/ui/dialogs/FillDialog.kt +++ b/ui/src/main/java/info/nightscout/ui/dialogs/FillDialog.kt @@ -118,11 +118,11 @@ class FillDialog : DialogFragmentWithDate() { val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(insulin)).value() if (insulinAfterConstraints > 0) { - actions.add(rh.gs(R.string.fillwarning)) + actions.add(rh.gs(R.string.fill_warning)) actions.add("") actions.add(rh.gs(R.string.bolus) + ": " + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints, activePlugin.activePump, rh).formatColor(context, rh, R.attr.insulinButtonColor)) if (abs(insulinAfterConstraints - insulin) > 0.01) - actions.add(rh.gs(R.string.bolusconstraintappliedwarn, insulin, insulinAfterConstraints).formatColor(context, rh, R.attr.warningColor)) + actions.add(rh.gs(R.string.bolus_constraint_applied_warn, insulin, insulinAfterConstraints).formatColor(context, rh, R.attr.warningColor)) } val siteChange = binding.fillCatheterChange.isChecked if (siteChange) diff --git a/ui/src/main/java/info/nightscout/ui/dialogs/InsulinDialog.kt b/ui/src/main/java/info/nightscout/ui/dialogs/InsulinDialog.kt index 8d5c53a3be..1c24c6061c 100644 --- a/ui/src/main/java/info/nightscout/ui/dialogs/InsulinDialog.kt +++ b/ui/src/main/java/info/nightscout/ui/dialogs/InsulinDialog.kt @@ -199,9 +199,9 @@ class InsulinDialog : DialogFragmentWithDate() { if (insulinAfterConstraints > 0) { actions.add(rh.gs(R.string.bolus) + ": " + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints, activePlugin.activePump, rh).formatColor(context, rh, R.attr.bolusColor)) if (recordOnlyChecked) - actions.add(rh.gs(R.string.bolusrecordedonly).formatColor(context, rh, R.attr.warningColor)) + actions.add(rh.gs(R.string.bolus_recorded_only).formatColor(context, rh, R.attr.warningColor)) if (abs(insulinAfterConstraints - insulin) > pumpDescription.pumpType.determineCorrectBolusStepSize(insulinAfterConstraints)) - actions.add(rh.gs(R.string.bolusconstraintappliedwarn, insulin, insulinAfterConstraints).formatColor(context, rh, R.attr.warningColor)) + actions.add(rh.gs(R.string.bolus_constraint_applied_warn, insulin, insulinAfterConstraints).formatColor(context, rh, R.attr.warningColor)) } val eatingSoonTTDuration = defaultValueHelper.determineEatingSoonTTDuration() val eatingSoonTT = defaultValueHelper.determineEatingSoonTT() diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt b/ui/src/main/java/info/nightscout/ui/dialogs/TreatmentDialog.kt similarity index 85% rename from app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt rename to ui/src/main/java/info/nightscout/ui/dialogs/TreatmentDialog.kt index 9f92ef79db..d1bcf813af 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt +++ b/ui/src/main/java/info/nightscout/ui/dialogs/TreatmentDialog.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.dialogs +package info.nightscout.ui.dialogs import android.content.Context import android.os.Bundle @@ -8,8 +8,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import com.google.common.base.Joiner -import info.nightscout.androidaps.R -import info.nightscout.androidaps.databinding.DialogTreatmentBinding +import info.nightscout.androidaps.dialogs.DialogFragmentWithDate import info.nightscout.androidaps.extensions.formatColor import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.CommandQueue @@ -19,11 +18,9 @@ import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.protection.ProtectionCheck -import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS import info.nightscout.core.pumpExtensions.insertBolusTransaction import info.nightscout.core.pumpExtensions.insertCarbsTransaction -import info.nightscout.database.entities.UserEntry.Action -import info.nightscout.database.entities.UserEntry.Sources +import info.nightscout.database.entities.UserEntry import info.nightscout.database.entities.ValueWithUnit import info.nightscout.database.impl.AppRepository import info.nightscout.interfaces.Config @@ -35,6 +32,8 @@ import info.nightscout.interfaces.utils.HtmlHelper import info.nightscout.rx.logging.LTag import info.nightscout.shared.SafeParse import info.nightscout.shared.interfaces.ResourceHelper +import info.nightscout.ui.R +import info.nightscout.ui.databinding.DialogTreatmentBinding import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign import java.text.DecimalFormat @@ -89,8 +88,10 @@ class TreatmentDialog : DialogFragmentWithDate() { savedInstanceState.putDouble("insulin", binding.insulin.value) } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle?): View { + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View { onCreateViewGeneral() _binding = DialogTreatmentBinding.inflate(inflater, container, false) return binding.root @@ -106,10 +107,14 @@ class TreatmentDialog : DialogFragmentWithDate() { val maxCarbs = constraintChecker.getMaxCarbsAllowed().value().toDouble() val maxInsulin = constraintChecker.getMaxBolusAllowed().value() val pumpDescription = activePlugin.activePump.pumpDescription - binding.carbs.setParams(savedInstanceState?.getDouble("carbs") - ?: 0.0, 0.0, maxCarbs, 1.0, DecimalFormat("0"), false, binding.okcancel.ok, textWatcher) - binding.insulin.setParams(savedInstanceState?.getDouble("insulin") - ?: 0.0, 0.0, maxInsulin, pumpDescription.bolusStep, DecimalFormatter.pumpSupportedBolusFormat(activePlugin.activePump), false, binding.okcancel.ok, textWatcher) + binding.carbs.setParams( + savedInstanceState?.getDouble("carbs") + ?: 0.0, 0.0, maxCarbs, 1.0, DecimalFormat("0"), false, binding.okcancel.ok, textWatcher + ) + binding.insulin.setParams( + savedInstanceState?.getDouble("insulin") + ?: 0.0, 0.0, maxInsulin, pumpDescription.bolusStep, DecimalFormatter.pumpSupportedBolusFormat(activePlugin.activePump), false, binding.okcancel.ok, textWatcher + ) binding.recordOnlyLayout.visibility = View.GONE binding.insulinLabel.labelFor = binding.insulin.editTextId binding.carbsLabel.labelFor = binding.carbs.editTextId @@ -133,9 +138,9 @@ class TreatmentDialog : DialogFragmentWithDate() { if (insulinAfterConstraints > 0) { actions.add(rh.gs(R.string.bolus) + ": " + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints, activePlugin.activePump, rh).formatColor(context, rh, R.attr.bolusColor)) if (recordOnlyChecked) - actions.add(rh.gs(R.string.bolusrecordedonly).formatColor(context, rh, R.attr.warningColor)) + actions.add(rh.gs(R.string.bolus_recorded_only).formatColor(context, rh, R.attr.warningColor)) if (abs(insulinAfterConstraints - insulin) > pumpDescription.pumpType.determineCorrectBolusStepSize(insulinAfterConstraints)) - actions.add(rh.gs(R.string.bolusconstraintappliedwarn, insulin, insulinAfterConstraints).formatColor(context, rh, R.attr.warningColor)) + actions.add(rh.gs(R.string.bolus_constraint_applied_warn, insulin, insulinAfterConstraints).formatColor(context, rh, R.attr.warningColor)) } if (carbsAfterConstraints > 0) { actions.add(rh.gs(R.string.carbs) + ": " + rh.gs(R.string.format_carbs, carbsAfterConstraints).formatColor(context, rh, R.attr.carbsColor)) @@ -146,9 +151,9 @@ class TreatmentDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, rh.gs(R.string.overview_treatment_label), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { val action = when { - insulinAfterConstraints.equals(0.0) -> Action.CARBS - carbsAfterConstraints == 0 -> Action.BOLUS - else -> Action.TREATMENT + insulinAfterConstraints.equals(0.0) -> UserEntry.Action.CARBS + carbsAfterConstraints == 0 -> UserEntry.Action.BOLUS + else -> UserEntry.Action.TREATMENT } val detailedBolusInfo = DetailedBolusInfo() if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = DetailedBolusInfo.EventType.CARBS_CORRECTION @@ -157,7 +162,7 @@ class TreatmentDialog : DialogFragmentWithDate() { detailedBolusInfo.carbs = carbsAfterConstraints.toDouble() detailedBolusInfo.context = context if (recordOnlyChecked) { - uel.log(action, Sources.TreatmentDialog, if (insulinAfterConstraints != 0.0) rh.gs(R.string.record) else "", + uel.log(action, UserEntry.Sources.TreatmentDialog, if (insulinAfterConstraints != 0.0) rh.gs(R.string.record) else "", ValueWithUnit.Timestamp(detailedBolusInfo.timestamp).takeIf { eventTimeChanged }, ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.record)).takeIf { insulinAfterConstraints != 0.0 }, ValueWithUnit.Insulin(insulinAfterConstraints).takeIf { insulinAfterConstraints != 0.0 }, @@ -176,7 +181,7 @@ class TreatmentDialog : DialogFragmentWithDate() { ) } else { if (detailedBolusInfo.insulin > 0) { - uel.log(action, Sources.TreatmentDialog, + uel.log(action, UserEntry.Sources.TreatmentDialog, ValueWithUnit.Insulin(insulinAfterConstraints), ValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbsAfterConstraints != 0 }) commandQueue.bolus(detailedBolusInfo, object : Callback() { @@ -187,7 +192,7 @@ class TreatmentDialog : DialogFragmentWithDate() { } }) } else { - uel.log(action, Sources.TreatmentDialog, + uel.log(action, UserEntry.Sources.TreatmentDialog, ValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbsAfterConstraints != 0 }) if (detailedBolusInfo.carbs > 0) { disposable += repository.runTransactionForResult(detailedBolusInfo.insertCarbsTransaction()) @@ -209,7 +214,7 @@ class TreatmentDialog : DialogFragmentWithDate() { override fun onResume() { super.onResume() - if(!queryingProtection) { + if (!queryingProtection) { queryingProtection = true activity?.let { activity -> val cancelFail = { @@ -218,8 +223,8 @@ class TreatmentDialog : DialogFragmentWithDate() { ToastUtils.warnToast(ctx, R.string.dialog_canceled) dismiss() } - protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail) + protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, { queryingProtection = false }, cancelFail, cancelFail) } } } -} +} \ No newline at end of file diff --git a/ui/src/main/res/layout/activity_profilehelper.xml b/ui/src/main/res/layout/activity_profilehelper.xml index 8f2094ebdc..a36174966f 100644 --- a/ui/src/main/res/layout/activity_profilehelper.xml +++ b/ui/src/main/res/layout/activity_profilehelper.xml @@ -36,7 +36,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" - android:hint="@string/profiletype" + android:hint="@string/profile_type" android:paddingHorizontal="5dp"> + app:customContentDescription="@string/basal_pct_from_tdd_label" /> @@ -240,7 +240,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableStart="@drawable/ic_compare_profiles" - android:text="@string/comapareprofile" /> + android:text="@string/compare_profile" /> diff --git a/app/src/main/res/layout/dialog_treatment.xml b/ui/src/main/res/layout/dialog_treatment.xml similarity index 100% rename from app/src/main/res/layout/dialog_treatment.xml rename to ui/src/main/res/layout/dialog_treatment.xml diff --git a/ui/src/main/res/values/strings.xml b/ui/src/main/res/values/strings.xml index 14a6f5ecfd..e56b9a986d 100644 --- a/ui/src/main/res/values/strings.xml +++ b/ui/src/main/res/values/strings.xml @@ -35,7 +35,7 @@ - Bolus constraint applied: %1$.2f U to %2$.2f U + Bolus constraint applied: %1$.2f U to %2$.2f U Glucose type Other @@ -50,8 +50,8 @@ Total - Please make sure the amount matches the specification of your infusion set! - Fill/Prime standard insulin amounts + Please make sure the amount matches the specification of your infusion set! + Fill/Prime standard insulin amounts Button 1 Button 2 Button 3 @@ -63,7 +63,7 @@ insulin_button_increment_2 insulin_button_increment_3 Do not bolus, record only - Bolus will be recorded only (not delivered by pump) + Bolus will be recorded only (not delivered by pump) @@ -103,18 +103,18 @@ Profile 1 Profile 2 - Profile type - % of basal + Profile type + % of basal Selected: - Compare profiles - Profile helper - Default profile - Current profile - Available profile - Age: %1$.0f TDD: %2$.0f U - Age: %1$.0f TDD: %2$.0f U %3$d%% - Age: %1$.0f Weight: %2$.0f kg - DPV Default profile - Invalid % entry + Compare profiles + Profile helper + Default profile + Current profile + Available profile + Age: %1$.0f TDD: %2$.0f U + Age: %1$.0f TDD: %2$.0f U %3$d%% + Age: %1$.0f Weight: %2$.0f kg + DPV Default profile + Invalid % entry