CareDialog -> ui module

This commit is contained in:
Milos Kozak 2022-11-04 16:07:32 +01:00
parent 571ab88451
commit cb2adc9fab
8 changed files with 39 additions and 37 deletions

View file

@ -10,7 +10,6 @@ import info.nightscout.androidaps.activities.fragments.TreatmentsProfileSwitchFr
import info.nightscout.androidaps.activities.fragments.TreatmentsTempTargetFragment import info.nightscout.androidaps.activities.fragments.TreatmentsTempTargetFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsTemporaryBasalsFragment import info.nightscout.androidaps.activities.fragments.TreatmentsTemporaryBasalsFragment
import info.nightscout.androidaps.activities.fragments.TreatmentsUserEntryFragment import info.nightscout.androidaps.activities.fragments.TreatmentsUserEntryFragment
import info.nightscout.androidaps.dialogs.CareDialog
import info.nightscout.androidaps.dialogs.ExtendedBolusDialog import info.nightscout.androidaps.dialogs.ExtendedBolusDialog
import info.nightscout.androidaps.dialogs.FillDialog import info.nightscout.androidaps.dialogs.FillDialog
import info.nightscout.androidaps.dialogs.InsulinDialog import info.nightscout.androidaps.dialogs.InsulinDialog
@ -74,8 +73,6 @@ abstract class FragmentsModule {
@ContributesAndroidInjector abstract fun contributesVirtualPumpFragment(): VirtualPumpFragment @ContributesAndroidInjector abstract fun contributesVirtualPumpFragment(): VirtualPumpFragment
@ContributesAndroidInjector abstract fun contributesCareDialog(): CareDialog
@ContributesAndroidInjector abstract fun contributesEditQuickWizardDialog(): EditQuickWizardDialog @ContributesAndroidInjector abstract fun contributesEditQuickWizardDialog(): EditQuickWizardDialog
@ContributesAndroidInjector abstract fun contributesExtendedBolusDialog(): ExtendedBolusDialog @ContributesAndroidInjector abstract fun contributesExtendedBolusDialog(): ExtendedBolusDialog

View file

@ -17,7 +17,6 @@ import info.nightscout.androidaps.database.ValueWrapper
import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.databinding.ActionsFragmentBinding import info.nightscout.androidaps.databinding.ActionsFragmentBinding
import info.nightscout.androidaps.dialogs.CareDialog
import info.nightscout.androidaps.dialogs.ExtendedBolusDialog import info.nightscout.androidaps.dialogs.ExtendedBolusDialog
import info.nightscout.androidaps.dialogs.FillDialog import info.nightscout.androidaps.dialogs.FillDialog
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
@ -56,6 +55,7 @@ import info.nightscout.androidaps.utils.ui.UIRunnable
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.ui.activities.TDDStatsActivity import info.nightscout.ui.activities.TDDStatsActivity
import info.nightscout.ui.dialogs.CareDialog
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import javax.inject.Inject import javax.inject.Inject

View file

@ -153,12 +153,8 @@
<string name="carbssuggestion">Carbs Suggestion</string> <string name="carbssuggestion">Carbs Suggestion</string>
<string name="unsupportednsversion">Unsupported version of Nightscout</string> <string name="unsupportednsversion">Unsupported version of Nightscout</string>
<string name="treatments_wizard_basaliob_label">Basal IOB</string> <string name="treatments_wizard_basaliob_label">Basal IOB</string>
<string name="careportal_newnstreatment_other">Other</string>
<string name="careportal_newnstreatment_meter">Meter</string>
<string name="careportal_newnstreatment_sensor">Sensor</string>
<string name="carb_time_label">Carb time</string> <string name="carb_time_label">Carb time</string>
<string name="profile_label">Profile</string> <string name="profile_label">Profile</string>
<string name="careportal_newnstreatment_glucosetype">Glucose type</string>
<string name="overview_tempbasal_button">TempBasal</string> <string name="overview_tempbasal_button">TempBasal</string>
<string name="overview_extendedbolus_button">Extended Bolus</string> <string name="overview_extendedbolus_button">Extended Bolus</string>
<string name="configbuilder_nightscoutversion_label">Nightscout version:</string> <string name="configbuilder_nightscoutversion_label">Nightscout version:</string>
@ -435,7 +431,6 @@
<string name="wearcontrol_title">Controls from Watch</string> <string name="wearcontrol_title">Controls from Watch</string>
<string name="wearcontrol_summary">Set Temp-Targets and enter Treatments from the watch.</string> <string name="wearcontrol_summary">Set Temp-Targets and enter Treatments from the watch.</string>
<string name="food">Food</string> <string name="food">Food</string>
<string name="none"><![CDATA[<none>]]></string>
<string name="shortkilojoul">kJ</string> <string name="shortkilojoul">kJ</string>
<string name="shortenergy">En</string> <string name="shortenergy">En</string>
<string name="shortprotein">Pr</string> <string name="shortprotein">Pr</string>

View file

@ -2,13 +2,14 @@ package info.nightscout.ui.di
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.ui.activities.SurveyActivity
import info.nightscout.ui.activities.BolusProgressHelperActivity import info.nightscout.ui.activities.BolusProgressHelperActivity
import info.nightscout.ui.activities.ErrorHelperActivity import info.nightscout.ui.activities.ErrorHelperActivity
import info.nightscout.ui.activities.StatsActivity import info.nightscout.ui.activities.StatsActivity
import info.nightscout.ui.activities.SurveyActivity
import info.nightscout.ui.activities.TDDStatsActivity import info.nightscout.ui.activities.TDDStatsActivity
import info.nightscout.ui.dialogs.CalibrationDialog import info.nightscout.ui.dialogs.CalibrationDialog
import info.nightscout.ui.dialogs.CarbsDialog import info.nightscout.ui.dialogs.CarbsDialog
import info.nightscout.ui.dialogs.CareDialog
@Module @Module
@Suppress("unused") @Suppress("unused")
@ -16,6 +17,7 @@ abstract class UiModule {
@ContributesAndroidInjector abstract fun contributesCalibrationDialog(): CalibrationDialog @ContributesAndroidInjector abstract fun contributesCalibrationDialog(): CalibrationDialog
@ContributesAndroidInjector abstract fun contributesCarbsDialog(): CarbsDialog @ContributesAndroidInjector abstract fun contributesCarbsDialog(): CarbsDialog
@ContributesAndroidInjector abstract fun contributesCareDialog(): CareDialog
@ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity @ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity
@ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity @ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.dialogs package info.nightscout.ui.dialogs
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
@ -11,30 +11,30 @@ import androidx.annotation.StringRes
import com.google.common.base.Joiner import com.google.common.base.Joiner
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.entities.TherapyEvent import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.transactions.InsertIfNewByTimestampTherapyEventTransaction import info.nightscout.androidaps.database.transactions.InsertIfNewByTimestampTherapyEventTransaction
import info.nightscout.androidaps.databinding.DialogCareBinding import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
import info.nightscout.androidaps.extensions.fromConstant
import info.nightscout.androidaps.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.utils.HtmlHelper import info.nightscout.androidaps.utils.HtmlHelper
import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.Translator import info.nightscout.androidaps.utils.Translator
import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.extensions.fromConstant import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.interfaces.GlucoseUnit import info.nightscout.ui.R
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.ui.databinding.DialogCareBinding
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import java.text.DecimalFormat import java.text.DecimalFormat
import java.util.* import java.util.LinkedList
import javax.inject.Inject import javax.inject.Inject
class CareDialog : DialogFragmentWithDate() { class CareDialog : DialogFragmentWithDate() {
@ -142,8 +142,10 @@ class CareDialog : DialogFragmentWithDate() {
} }
} }
val bg = Profile.fromMgdlToUnits(glucoseStatusProvider.glucoseStatusData?.glucose val bg = Profile.fromMgdlToUnits(
?: 0.0, profileFunction.getUnits()) glucoseStatusProvider.glucoseStatusData?.glucose
?: 0.0, profileFunction.getUnits()
)
val bgTextWatcher: TextWatcher = object : TextWatcher { val bgTextWatcher: TextWatcher = object : TextWatcher {
override fun afterTextChanged(s: Editable) {} override fun afterTextChanged(s: Editable) {}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {} override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
@ -202,7 +204,7 @@ class CareDialog : DialogFragmentWithDate() {
binding.sensor.isChecked -> TherapyEvent.MeterType.SENSOR binding.sensor.isChecked -> TherapyEvent.MeterType.SENSOR
else -> TherapyEvent.MeterType.MANUAL else -> TherapyEvent.MeterType.MANUAL
} }
actions.add(rh.gs(R.string.careportal_newnstreatment_glucosetype) + ": " + translator.translate(meterType)) actions.add(rh.gs(R.string.glucose_type) + ": " + translator.translate(meterType))
actions.add(rh.gs(R.string.bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, binding.bg.value) + " " + rh.gs(unitResId)) actions.add(rh.gs(R.string.bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, binding.bg.value) + " " + rh.gs(unitResId))
therapyEvent.glucoseType = meterType therapyEvent.glucoseType = meterType
therapyEvent.glucose = binding.bg.value therapyEvent.glucose = binding.bg.value
@ -225,13 +227,13 @@ class CareDialog : DialogFragmentWithDate() {
therapyEvent.enteredBy = enteredBy therapyEvent.enteredBy = enteredBy
val source = when (options) { val source = when (options) {
EventType.BGCHECK -> Sources.BgCheck EventType.BGCHECK -> UserEntry.Sources.BgCheck
EventType.SENSOR_INSERT -> Sources.SensorInsert EventType.SENSOR_INSERT -> UserEntry.Sources.SensorInsert
EventType.BATTERY_CHANGE -> Sources.BatteryChange EventType.BATTERY_CHANGE -> UserEntry.Sources.BatteryChange
EventType.NOTE -> Sources.Note EventType.NOTE -> UserEntry.Sources.Note
EventType.EXERCISE -> Sources.Exercise EventType.EXERCISE -> UserEntry.Sources.Exercise
EventType.QUESTION -> Sources.Question EventType.QUESTION -> UserEntry.Sources.Question
EventType.ANNOUNCEMENT -> Sources.Announcement EventType.ANNOUNCEMENT -> UserEntry.Sources.Announcement
} }
activity?.let { activity -> activity?.let { activity ->
@ -243,9 +245,9 @@ class CareDialog : DialogFragmentWithDate() {
) )
valuesWithUnit.add(0, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }) valuesWithUnit.add(0, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged })
valuesWithUnit.add(1, ValueWithUnit.TherapyEventType(therapyEvent.type)) valuesWithUnit.add(1, ValueWithUnit.TherapyEventType(therapyEvent.type))
uel.log(Action.CAREPORTAL, source, notes, valuesWithUnit) uel.log(UserEntry.Action.CAREPORTAL, source, notes, valuesWithUnit)
}, null) }, null)
} }
return true return true
} }
} }

View file

@ -60,20 +60,20 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:checked="false" android:checked="false"
android:text="@string/careportal_newnstreatment_meter" /> android:text="@string/bg_meter" />
<RadioButton <RadioButton
android:id="@+id/sensor" android:id="@+id/sensor"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:checked="true" android:checked="true"
android:text="@string/careportal_newnstreatment_sensor" /> android:text="@string/bg_sensor" />
<RadioButton <RadioButton
android:id="@+id/other" android:id="@+id/other"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/careportal_newnstreatment_other" /> android:text="@string/bg_other" />
</RadioGroup> </RadioGroup>

View file

@ -35,5 +35,11 @@
<string name="most_common_profile">Most common profile:</string> <string name="most_common_profile">Most common profile:</string>
<string name="survey_comment">Note: Only data visible on this screen will be anonymously uploaded. ID is assigned to this installation of AAPS. You can submit data again if your main profile get changed but let it running at least for a week to make result visible in time in range. Your help is appreciated.</string> <string name="survey_comment">Note: Only data visible on this screen will be anonymously uploaded. ID is assigned to this installation of AAPS. You can submit data again if your main profile get changed but let it running at least for a week to make result visible in time in range. Your help is appreciated.</string>
<!-- CareDialog -->
<string name="glucose_type">Glucose type</string>
<string name="bg_other">Other</string>
<string name="bg_meter">Meter</string>
<string name="bg_sensor">Sensor</string>
<string name="none"><![CDATA[<none>]]></string>
</resources> </resources>