StatuLinePlugin -> plugins module

This commit is contained in:
Milos Kozak 2022-11-04 15:46:22 +01:00
parent c5ae87d344
commit 571ab88451
17 changed files with 65 additions and 62 deletions

View file

@ -43,7 +43,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
import info.nightscout.androidaps.plugins.general.tidepool.TidepoolPlugin
import info.nightscout.androidaps.plugins.general.wear.WearPlugin
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatusLinePlugin
import info.nightscout.plugins.general.xdripStatusline.StatusLinePlugin
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin
import info.nightscout.androidaps.plugins.pump.eopatch.EopatchPumpPlugin
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin

View file

@ -34,7 +34,6 @@ import info.nightscout.androidaps.plugins.general.persistentNotification.Persist
import info.nightscout.androidaps.plugins.general.themes.ThemeSwitcherPlugin
import info.nightscout.androidaps.plugins.general.tidepool.TidepoolPlugin
import info.nightscout.androidaps.plugins.general.wear.WearPlugin
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatusLinePlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin
@ -60,6 +59,7 @@ import info.nightscout.androidaps.plugins.source.TomatoPlugin
import info.nightscout.androidaps.plugins.source.XdripPlugin
import info.nightscout.automation.AutomationPlugin
import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.plugins.general.xdripStatusline.StatusLinePlugin
import info.nightscout.plugins.insulin.InsulinLyumjevPlugin
import info.nightscout.plugins.insulin.InsulinOrefFreePeakPlugin
import info.nightscout.plugins.insulin.InsulinOrefRapidActingPlugin

View file

@ -710,7 +710,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
else -> {
binding.infoLayout.apsMode.setImageResource(R.drawable.ic_loop_disabled)
apsModeSetA11yLabel(R.string.disabledloop)
apsModeSetA11yLabel(R.string.disabled_loop)
binding.infoLayout.apsModeText.visibility = View.GONE
}
}

View file

@ -1079,7 +1079,7 @@ class DataHandlerMobile @Inject constructor(
private fun generateStatusString(profile: Profile?, currentBasal: String, iobSum: String, iobDetail: String, bgiString: String): String {
var status = ""
profile ?: return rh.gs(R.string.noprofile)
if (!(loop as PluginBase).isEnabled()) status += rh.gs(R.string.disabledloop) + "\n"
if (!(loop as PluginBase).isEnabled()) status += rh.gs(R.string.disabled_loop) + "\n"
val iobString =
if (sp.getBoolean(R.string.key_wear_detailediob, false)) "$iobSum $iobDetail"

View file

@ -88,7 +88,6 @@
<string name="description_source_xdrip">Receive BG values from xDrip+.</string>
<string name="description_treatments">Saves all treatments that were made</string>
<string name="description_wear">Monitor and control AAPS using your WearOS watch.</string>
<string name="description_xdrip_status_line">Show information about your loop on your xDrip+ watchface.</string>
<string name="treatments_insulin_label_string">Insulin:</string>
<string name="treatments_carbs_label_string">Carbs:</string>
<string name="treatments_iob_label_string">IOB:</string>
@ -149,8 +148,7 @@
<string name="apsmode_title">APS Mode</string>
<string name="closedloop">Closed Loop</string>
<string name="openloop">Open Loop</string>
<string name="lowglucosesuspend">Low Glucose Suspend</string>
<string name="disabledloop">Loop Disabled</string>
<string name="lowglucosesuspend">Low Glucose Suspend</string>
<string name="openloop_newsuggestion">New suggestion available</string>
<string name="carbssuggestion">Carbs Suggestion</string>
<string name="unsupportednsversion">Unsupported version of Nightscout</string>
@ -290,8 +288,6 @@
<string name="key_nsclientinternal_paused" translatable="false">nsclientinternal_paused</string>
<string name="nowritepermission">NSCLIENT has no write permission. Wrong API secret?</string>
<string name="wear_settings">Wear settings</string>
<string name="wear_detailedIOB_title">Show detailed IOB</string>
<string name="wear_detailedIOB_summary">Break down IOB into bolus and basal IOB on the watchface</string>
<string name="nosuccess">not successful - please check phone</string>
<string name="patientage">Patient type</string>
<string name="child">Child</string>
@ -370,11 +366,6 @@
<string name="devslope_shortname">DEVSLOPE</string>
<string name="nav_about">About</string>
<string name="smscommunicator_missingphonestatepermission">Missing phone state permission</string>
<string name="xdripstatus_settings">xDrip+ Status (watch)</string>
<string name="xdripstatus">xDrip+ Statusline (watch)</string>
<string name="xdripstatus_shortname">xds</string>
<string name="wear_showbgi_title">Show BGI</string>
<string name="wear_showbgi_summary">Add BGI to status line</string>
<string name="overview_extendedbolus_cancel_button">Cancel Extended Bolus</string>
<string name="doprofileswitch">Do Profile Switch</string>
<string name="careportal_sensor_label">Sensor</string>
@ -808,8 +799,6 @@
<string name="show_calculation">Show calcuation</string>
<string name="show_removed">Show removed</string>
<string name="clearqueueconfirm">Clear queue? All data in queue will be lost!</string>
<string name="key_xdripstatus_detailediob" translatable="false">xdripstatus_detailediob</string>
<string name="key_xdripstatus_showbgi" translatable="false">xdripstatus_showbgi</string>
<string name="key_wear_detailed_delta" translatable="false">wear_detailed_delta</string>
<string name="key_snoozedTo" translatable="false">snoozedTo</string>
<string name="key_snooze_dst_in24h" translatable="false">snooze_dst_in24h</string>

View file

@ -56,8 +56,8 @@
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_wear_detailediob"
android:summary="@string/wear_detailedIOB_summary"
android:title="@string/wear_detailedIOB_title" />
android:summary="@string/xdrip_status_detailed_iob_summary"
android:title="@string/xdrip_status_detailed_iob_title" />
<SwitchPreference
android:defaultValue="false"
@ -68,8 +68,8 @@
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_wear_showbgi"
android:summary="@string/wear_showbgi_summary"
android:title="@string/wear_showbgi_title" />
android:summary="@string/xdrip_status_show_bgi_summary"
android:title="@string/xdrip_status_show_bgi_title" />
<SwitchPreference
android:defaultValue="true"
android:key="wear_predictions"

View file

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="@string/key_xdripstatus_settings"
android:title="@string/xdripstatus_settings"
app:initialExpandedChildrenCount="0">
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_xdripstatus_detailediob"
android:summary="@string/wear_detailedIOB_summary"
android:title="@string/wear_detailedIOB_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_xdripstatus_showbgi"
android:summary="@string/wear_showbgi_summary"
android:title="@string/wear_showbgi_title" />
</PreferenceCategory>
</androidx.preference.PreferenceScreen>

View file

@ -49,7 +49,6 @@
<string name="key_openapsma_settings" translatable="false">openapsma_settings</string>
<string name="key_medtronic_settings" translatable="false">medtronic_settings</string>
<string name="key_danars_settings" translatable="false">danars_settings</string>
<string name="key_xdripstatus_settings" translatable="false">xdripstatus_settings</string>
<string name="key_nsclientinternal_settings" translatable="false">nsclientinternal_settings</string>
<string name="key_insight_local_settings" translatable="false">insight_local_settings</string>
<string name="key_data_choices_settings" translatable="false">data_choices_settings</string>

View file

@ -1,10 +1,9 @@
package info.nightscout.androidaps.plugins.general.xdripStatusline
package info.nightscout.plugins.general.xdripStatusline
import android.content.Context
import android.content.Intent
import android.os.Bundle
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.*
import info.nightscout.androidaps.extensions.toStringShort
import info.nightscout.androidaps.interfaces.*
@ -12,6 +11,7 @@ import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.plugins.R
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.rxjava3.disposables.CompositeDisposable
@ -36,8 +36,8 @@ class StatusLinePlugin @Inject constructor(
PluginDescription()
.mainType(PluginType.GENERAL)
.pluginIcon((R.drawable.ic_blooddrop_48))
.pluginName(R.string.xdripstatus)
.shortName(R.string.xdripstatus_shortname)
.pluginName(R.string.xdrip_status)
.shortName(R.string.xdrip_status_shortname)
.neverVisible(true)
.preferencesId(R.xml.pref_xdripstatus)
.description(R.string.description_xdrip_status_line),
@ -112,7 +112,7 @@ class StatusLinePlugin @Inject constructor(
private fun buildStatusString(profile: Profile): String {
var status = ""
if (!(loop as PluginBase).isEnabled()) {
status += rh.gs(R.string.disabledloop) + "\n"
status += rh.gs(R.string.disabled_loop) + "\n"
lastLoopStatus = false
} else lastLoopStatus = true
@ -125,12 +125,12 @@ class StatusLinePlugin @Inject constructor(
val bolusIob = iobCobCalculator.calculateIobFromBolus().round()
val basalIob = iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended().round()
status += DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U"
if (sp.getBoolean(R.string.key_xdripstatus_detailediob, true)) {
if (sp.getBoolean(R.string.key_xdrip_status_detailed_iob, true)) {
status += ("("
+ DecimalFormatter.to2Decimal(bolusIob.iob) + "|"
+ DecimalFormatter.to2Decimal(basalIob.basaliob) + ")")
}
if (sp.getBoolean(R.string.key_xdripstatus_showbgi, true)) {
if (sp.getBoolean(R.string.key_xdrip_status_show_bgi, true)) {
val bgi = -(bolusIob.activity + basalIob.activity) * 5 * Profile.fromMgdlToUnits(profile.getIsfMgdl(), profileFunction.getUnits())
status += " " + (if (bgi >= 0) "+" else "") + DecimalFormatter.to2Decimal(bgi)
}

View file

@ -33,7 +33,7 @@ class InsulinOrefRapidActingPlugin @Inject constructor(
override fun configuration(): JSONObject = JSONObject()
override fun applyConfiguration(configuration: JSONObject) {}
override fun commentStandardText(): String = rh.gs(R.string.fastactinginsulincomment)
override fun commentStandardText(): String = rh.gs(R.string.fast_acting_insulin_comment)
override val peak = 75

View file

@ -28,18 +28,18 @@ class InsulinOrefUltraRapidActingPlugin @Inject constructor(
) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger, config, hardLimits) {
override val id get(): Insulin.InsulinType = Insulin.InsulinType.OREF_ULTRA_RAPID_ACTING
override val friendlyName get(): String = rh.gs(R.string.ultrarapid_oref)
override val friendlyName get(): String = rh.gs(R.string.ultra_rapid_oref)
override fun configuration(): JSONObject = JSONObject()
override fun applyConfiguration(configuration: JSONObject) {}
override fun commentStandardText(): String = rh.gs(R.string.ultrafastactinginsulincomment)
override fun commentStandardText(): String = rh.gs(R.string.ultra_fast_acting_insulin_comment)
override val peak = 55
init {
pluginDescription
.pluginName(R.string.ultrarapid_oref)
.pluginName(R.string.ultra_rapid_oref)
.description(R.string.description_insulin_ultra_rapid)
}
}

View file

@ -127,9 +127,24 @@
<string name="insulin_peak">Peak</string>
<string name="free_peak_oref">Free-Peak Oref</string>
<string name="rapid_acting_oref">Rapid-Acting Oref</string>
<string name="ultrarapid_oref">Ultra-Rapid Oref</string>
<string name="ultra_rapid_oref">Ultra-Rapid Oref</string>
<string name="dia_too_short">DIA of %1$f too short - using %2$f instead!</string>
<string name="fastactinginsulincomment">Novorapid, Novolog, Humalog</string>
<string name="ultrafastactinginsulincomment">Fiasp</string>
<string name="fast_acting_insulin_comment">Novorapid, Novolog, Humalog</string>
<string name="ultra_fast_acting_insulin_comment">Fiasp</string>
<!-- xDrip status line -->
<string name="key_xdrip_status_detailed_iob" translatable="false">xdripstatus_detailediob</string>
<string name="key_xdrip_status_show_bgi" translatable="false">xdripstatus_showbgi</string>
<string name="key_xdrip_status_settings" translatable="false">xdripstatus_settings</string>
<string name="xdrip_status">xDrip+ Statusline (watch)</string>
<string name="xdrip_status_shortname">xds</string>
<string name="description_xdrip_status_line">Show information about your loop on your xDrip+ watchface.</string>
<string name="xdrip_status_detailed_iob_title">Show detailed IOB</string>
<string name="xdrip_status_detailed_iob_summary">Break down IOB into bolus and basal IOB on the watchface</string>
<string name="disabled_loop">Loop Disabled</string>
<string name="xdrip_status_show_bgi_title">Show BGI</string>
<string name="xdrip_status_show_bgi_summary">Add BGI to status line</string>
<string name="xdrip_status_settings">xDrip+ Status (watch)</string>
</resources>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="@string/key_xdrip_status_settings"
android:title="@string/xdrip_status_settings"
app:initialExpandedChildrenCount="0">
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_xdrip_status_detailed_iob"
android:summary="@string/xdrip_status_detailed_iob_summary"
android:title="@string/xdrip_status_detailed_iob_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_xdrip_status_show_bgi"
android:summary="@string/xdrip_status_show_bgi_summary"
android:title="@string/xdrip_status_show_bgi_title" />
</PreferenceCategory>
</androidx.preference.PreferenceScreen>

View file

@ -56,7 +56,7 @@ class InsulinOrefRapidActingPluginTest {
@Test
fun commentStandardTextTest() {
`when`(rh.gs(eq(R.string.fastactinginsulincomment))).thenReturn("Novorapid, Novolog, Humalog")
`when`(rh.gs(eq(R.string.fast_acting_insulin_comment))).thenReturn("Novorapid, Novolog, Humalog")
assertEquals("Novorapid, Novolog, Humalog", sut.commentStandardText())
}

View file

@ -56,13 +56,13 @@ class InsulinOrefUltraRapidActingPluginTest {
@Test
fun commentStandardTextTest() {
`when`(rh.gs(eq(R.string.ultrafastactinginsulincomment))).thenReturn("Fiasp")
`when`(rh.gs(eq(R.string.ultra_fast_acting_insulin_comment))).thenReturn("Fiasp")
assertEquals("Fiasp", sut.commentStandardText())
}
@Test
fun getFriendlyNameTest() {
`when`(rh.gs(eq(R.string.ultrarapid_oref))).thenReturn("Ultra-Rapid Oref")
`when`(rh.gs(eq(R.string.ultra_rapid_oref))).thenReturn("Ultra-Rapid Oref")
assertEquals("Ultra-Rapid Oref", sut.friendlyName)
}