Add Calibration in Translator.kt

Replace strings by Constants defined in CareportalEvent (most of them already defined)
8 Constants added in CareportalEvent file (3 types used in CareDialog.kt and Translator.kt, 5 only used in translator.kt)
=> I don't know if these types still exists now without CarePortal Plugin...
This commit is contained in:
Philoul 2020-08-22 18:33:13 +02:00
parent 8c987c8be9
commit 0d3d83806b
4 changed files with 44 additions and 28 deletions

View file

@ -156,9 +156,9 @@ class CareDialog : DialogFragmentWithDate() {
if (options == EventType.BGCHECK || options == EventType.QUESTION || options == EventType.ANNOUNCEMENT) { if (options == EventType.BGCHECK || options == EventType.QUESTION || options == EventType.ANNOUNCEMENT) {
val type = val type =
when { when {
actions_care_meter.isChecked -> "Finger" actions_care_meter.isChecked -> CareportalEvent.FINGER
actions_care_sensor.isChecked -> "Sensor" actions_care_sensor.isChecked -> CareportalEvent.SENSOR
else -> "Manual" else -> CareportalEvent.MANUAL
} }
actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_glucosetype) + ": " + translator.translate(type)) actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_glucosetype) + ": " + translator.translate(type))
actions.add(resourceHelper.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, actions_care_bg.value) + " " + resourceHelper.gs(unitResId)) actions.add(resourceHelper.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, actions_care_bg.value) + " " + resourceHelper.gs(unitResId))

View file

@ -78,6 +78,18 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
public static final String MBG = "Mbg"; // comming from entries public static final String MBG = "Mbg"; // comming from entries
// found in CareDialog.kt file
public static final String FINGER = "Finger";
public static final String SENSOR = "Sensor";
public static final String MANUAL = "Manual";
// found in Translator.kt
public static final String SNACKBOLUS = "Snack Bolus";
public static final String SENSORSTART = "Sensor Start";
public static final String TEMPBASALSTART = "Temp Basal Start";
public static final String TEMPBASALEND = "Temp Basal End";
public static final String TEMPBASALCANCEL = "Temporary Target Cancel";
@Deprecated @Deprecated
public CareportalEvent() { public CareportalEvent() {
StaticInjector.Companion.getInstance().androidInjector().inject(this); StaticInjector.Companion.getInstance().androidInjector().inject(this);

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.utils package info.nightscout.androidaps.utils
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.db.CareportalEvent
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -15,30 +16,32 @@ class Translator @Inject internal constructor(
fun translate(text: String): String = fun translate(text: String): String =
when (text) { when (text) {
"BG Check" -> resourceHelper.gs(R.string.careportal_bgcheck) CareportalEvent.BGCHECK -> resourceHelper.gs(R.string.careportal_bgcheck)
"Snack Bolus" -> resourceHelper.gs(R.string.careportal_snackbolus) CareportalEvent.SNACKBOLUS -> resourceHelper.gs(R.string.careportal_snackbolus)
"Meal Bolus" -> resourceHelper.gs(R.string.careportal_mealbolus) CareportalEvent.MEALBOLUS -> resourceHelper.gs(R.string.careportal_mealbolus)
"Correction Bolus" -> resourceHelper.gs(R.string.careportal_correctionbolus) CareportalEvent.CORRECTIONBOLUS -> resourceHelper.gs(R.string.careportal_correctionbolus)
"Carb Correction" -> resourceHelper.gs(R.string.careportal_carbscorrection) CareportalEvent.CARBCORRECTION -> resourceHelper.gs(R.string.careportal_carbscorrection)
"Combo Bolus" -> resourceHelper.gs(R.string.careportal_combobolus) CareportalEvent.COMBOBOLUS -> resourceHelper.gs(R.string.careportal_combobolus)
"Announcement" -> resourceHelper.gs(R.string.careportal_announcement) CareportalEvent.ANNOUNCEMENT -> resourceHelper.gs(R.string.careportal_announcement)
"Note" -> resourceHelper.gs(R.string.careportal_note) CareportalEvent.NOTE -> resourceHelper.gs(R.string.careportal_note)
"Question" -> resourceHelper.gs(R.string.careportal_question) CareportalEvent.QUESTION -> resourceHelper.gs(R.string.careportal_question)
"Exercise" -> resourceHelper.gs(R.string.careportal_exercise) CareportalEvent.EXERCISE -> resourceHelper.gs(R.string.careportal_exercise)
"Site Change" -> resourceHelper.gs(R.string.careportal_pumpsitechange) CareportalEvent.SITECHANGE -> resourceHelper.gs(R.string.careportal_pumpsitechange)
"Pump Battery Change" -> resourceHelper.gs(R.string.careportal_pumpbatterychange) CareportalEvent.PUMPBATTERYCHANGE -> resourceHelper.gs(R.string.careportal_pumpbatterychange)
"Sensor Start" -> resourceHelper.gs(R.string.careportal_cgmsensorstart) CareportalEvent.SENSORSTART -> resourceHelper.gs(R.string.careportal_cgmsensorstart)
"Sensor Change" -> resourceHelper.gs(R.string.careportal_cgmsensorinsert) CareportalEvent.SENSORCHANGE -> resourceHelper.gs(R.string.careportal_cgmsensorinsert)
"Insulin Change" -> resourceHelper.gs(R.string.careportal_insulincartridgechange) CareportalEvent.INSULINCHANGE -> resourceHelper.gs(R.string.careportal_insulincartridgechange)
"Temp Basal Start" -> resourceHelper.gs(R.string.careportal_tempbasalstart) CareportalEvent.TEMPBASALSTART -> resourceHelper.gs(R.string.careportal_tempbasalstart)
"Temp Basal End" -> resourceHelper.gs(R.string.careportal_tempbasalend) CareportalEvent.TEMPBASALEND -> resourceHelper.gs(R.string.careportal_tempbasalend)
"Profile Switch" -> resourceHelper.gs(R.string.careportal_profileswitch) CareportalEvent.PROFILESWITCH -> resourceHelper.gs(R.string.careportal_profileswitch)
"Temporary Target" -> resourceHelper.gs(R.string.careportal_temporarytarget) CareportalEvent.TEMPORARYTARGET -> resourceHelper.gs(R.string.careportal_temporarytarget)
"Temporary Target Cancel" -> resourceHelper.gs(R.string.careportal_temporarytargetcancel) CareportalEvent.TEMPBASALCANCEL -> resourceHelper.gs(R.string.careportal_temporarytargetcancel)
"OpenAPS Offline" -> resourceHelper.gs(R.string.careportal_openapsoffline) CareportalEvent.OPENAPSOFFLINE -> resourceHelper.gs(R.string.careportal_openapsoffline)
"Finger" -> resourceHelper.gs(R.string.glucosetype_finger) CareportalEvent.MBG -> resourceHelper.gs(R.string.careportal_calibration)
"Sensor" -> resourceHelper.gs(R.string.glucosetype_sensor)
"Manual" -> resourceHelper.gs(R.string.manual) CareportalEvent.FINGER -> resourceHelper.gs(R.string.glucosetype_finger)
else -> resourceHelper.gs(R.string.unknown) CareportalEvent.SENSOR -> resourceHelper.gs(R.string.glucosetype_sensor)
CareportalEvent.MANUAL -> resourceHelper.gs(R.string.manual)
else -> resourceHelper.gs(R.string.unknown)
} }
} }

View file

@ -163,6 +163,7 @@
<!-- Translator--> <!-- Translator-->
<string name="careportal_bgcheck">BG Check</string> <string name="careportal_bgcheck">BG Check</string>
<string name="careportal_calibration">Calibration</string>
<string name="careportal_announcement">Announcement</string> <string name="careportal_announcement">Announcement</string>
<string name="careportal_note">Note</string> <string name="careportal_note">Note</string>
<string name="careportal_question">Question</string> <string name="careportal_question">Question</string>