StatusLinePlugin -> kt, dagger
This commit is contained in:
parent
3c58559a75
commit
377b5a9991
8 changed files with 154 additions and 253 deletions
|
@ -60,7 +60,7 @@ import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin;
|
|||
import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.wear.WearPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatuslinePlugin;
|
||||
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatusLinePlugin;
|
||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin;
|
||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefRapidActingPlugin;
|
||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefUltraRapidActingPlugin;
|
||||
|
@ -126,9 +126,7 @@ public class MainApp extends DaggerApplication {
|
|||
@Inject
|
||||
AAPSLogger aapsLogger;
|
||||
|
||||
@Inject
|
||||
ConfigBuilderPlugin configBuilderPlugin;
|
||||
|
||||
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
||||
@Inject InsulinOrefFreePeakPlugin insulinOrefFreePeakPlugin;
|
||||
@Inject InsulinOrefRapidActingPlugin insulinOrefRapidActingPlugin;
|
||||
@Inject InsulinOrefUltraRapidActingPlugin insulinOrefUltraRapidActingPlugin;
|
||||
|
@ -137,6 +135,7 @@ public class MainApp extends DaggerApplication {
|
|||
@Inject OpenAPSMAPlugin openAPSMAPlugin;
|
||||
@Inject OpenAPSAMAPlugin openAPSAMAPlugin;
|
||||
@Inject OpenAPSSMBPlugin openAPSSMBPlugin;
|
||||
@Inject StatusLinePlugin statusLinePlugin;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
@ -235,7 +234,7 @@ public class MainApp extends DaggerApplication {
|
|||
pluginsList.add(FoodPlugin.getPlugin());
|
||||
|
||||
pluginsList.add(WearPlugin.initPlugin(this));
|
||||
pluginsList.add(StatuslinePlugin.initPlugin(this));
|
||||
pluginsList.add(statusLinePlugin);
|
||||
pluginsList.add(PersistentNotificationPlugin.getPlugin());
|
||||
pluginsList.add(NSClientPlugin.getPlugin());
|
||||
// if (engineeringMode) pluginsList.add(TidepoolPlugin.INSTANCE);
|
||||
|
|
|
@ -25,7 +25,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
|
|||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin;
|
||||
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.general.xdripStatusline.StatusLinePlugin;
|
||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
||||
|
@ -52,21 +52,18 @@ public class MyPreferenceFragment extends PreferenceFragment implements HasAndro
|
|||
|
||||
@Inject
|
||||
OpenAPSAMAPlugin openAPSAMAPlugin;
|
||||
|
||||
@Inject
|
||||
OpenAPSMAPlugin openAPSMAPlugin;
|
||||
|
||||
@Inject
|
||||
OpenAPSSMBPlugin openAPSSMBPlugin;
|
||||
|
||||
@Inject
|
||||
InsulinOrefFreePeakPlugin insulinOrefFreePeakPlugin;
|
||||
|
||||
@Inject
|
||||
SafetyPlugin safetyPlugin;
|
||||
|
||||
@Inject
|
||||
SmsCommunicatorPlugin smsCommunicatorPlugin;
|
||||
@Inject
|
||||
StatusLinePlugin statusLinePlugin;
|
||||
|
||||
@Override
|
||||
public void setArguments(Bundle args) {
|
||||
|
@ -130,13 +127,6 @@ public class MyPreferenceFragment extends PreferenceFragment implements HasAndro
|
|||
addPreferencesFromResourceIfEnabled(LocalInsightPlugin.getPlugin(), PluginType.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(ComboPlugin.getPlugin(), PluginType.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(MedtronicPumpPlugin.getPlugin(), PluginType.PUMP);
|
||||
|
||||
if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
||||
|| DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
||||
|| DanaRv2Plugin.getPlugin().isEnabled(PluginType.PROFILE)
|
||||
|| DanaRSPlugin.getPlugin().isEnabled(PluginType.PROFILE)) {
|
||||
addPreferencesFromResource(R.xml.pref_danarprofile);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Config.NSCLIENT) {
|
||||
|
@ -154,7 +144,7 @@ public class MyPreferenceFragment extends PreferenceFragment implements HasAndro
|
|||
addPreferencesFromResource(R.xml.pref_datachoices);
|
||||
|
||||
addPreferencesFromResourceIfEnabled(WearPlugin.getPlugin(), PluginType.GENERAL);
|
||||
addPreferencesFromResourceIfEnabled(StatuslinePlugin.getPlugin(), PluginType.GENERAL);
|
||||
addPreferencesFromResourceIfEnabled(statusLinePlugin, PluginType.GENERAL);
|
||||
}
|
||||
|
||||
PreferencesActivity.initSummary(getPreferenceScreen());
|
||||
|
|
|
@ -93,7 +93,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
super.onStart()
|
||||
disposable.add(toObservable(EventPreferenceChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ event: EventPreferenceChange? -> processSettings(event) }) { throwable: Throwable? -> FabricPrivacy.logException(throwable) }
|
||||
.subscribe({ event: EventPreferenceChange? -> processSettings(event) }) { FabricPrivacy.logException(it) }
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
package info.nightscout.androidaps.plugins.general.xdripStatusline
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.events.*
|
||||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface
|
||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus.toObservable
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class StatusLinePlugin @Inject constructor(
|
||||
private val sp: SP,
|
||||
private val profileFunction: ProfileFunction,
|
||||
private val resourceHelper: ResourceHelper,
|
||||
private val configBuilderPlugin: ConfigBuilderPlugin,
|
||||
private val mainApp: MainApp) : PluginBase(
|
||||
PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.pluginName(R.string.xdripstatus)
|
||||
.shortName(R.string.xdripstatus_shortname)
|
||||
.neverVisible(true)
|
||||
.preferencesId(R.xml.pref_xdripstatus)
|
||||
.description(R.string.description_xdrip_status_line)) {
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
private var lastLoopStatus = false
|
||||
|
||||
companion object {
|
||||
//broadcast related constants
|
||||
@Suppress("SpellCheckingInspection")
|
||||
private const val EXTRA_STATUSLINE = "com.eveningoutpost.dexdrip.Extras.Statusline"
|
||||
@Suppress("SpellCheckingInspection")
|
||||
private const val ACTION_NEW_EXTERNAL_STATUSLINE = "com.eveningoutpost.dexdrip.ExternalStatusline"
|
||||
@Suppress("SpellCheckingInspection", "unused")
|
||||
private const val RECEIVER_PERMISSION = "com.eveningoutpost.dexdrip.permissions.RECEIVE_EXTERNAL_STATUSLINE"
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
disposable.add(toObservable(EventRefreshOverview::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ if (lastLoopStatus != LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)) sendStatus() }) { FabricPrivacy.logException(it) })
|
||||
disposable.add(toObservable(EventExtendedBolusChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ sendStatus() }) { FabricPrivacy.logException(it) })
|
||||
disposable.add(toObservable(EventTempBasalChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ sendStatus() }) { FabricPrivacy.logException(it) })
|
||||
disposable.add(toObservable(EventTreatmentChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ sendStatus() }) { FabricPrivacy.logException(it) })
|
||||
disposable.add(toObservable(EventConfigBuilderChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ sendStatus() }) { FabricPrivacy.logException(it) })
|
||||
disposable.add(toObservable(EventAutosensCalculationFinished::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ sendStatus() }) { FabricPrivacy.logException(it) })
|
||||
disposable.add(toObservable(EventPreferenceChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ sendStatus() }) { FabricPrivacy.logException(it) })
|
||||
disposable.add(toObservable(EventAppInitialized::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ sendStatus() }) { FabricPrivacy.logException(it) })
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
disposable.clear()
|
||||
sendStatus()
|
||||
}
|
||||
|
||||
private fun sendStatus() {
|
||||
var status = "" // sent once on disable
|
||||
val profile = profileFunction.getProfile()
|
||||
if (isEnabled(PluginType.GENERAL) && profile != null) {
|
||||
status = buildStatusString(profile)
|
||||
}
|
||||
//sendData
|
||||
val bundle = Bundle()
|
||||
bundle.putString(EXTRA_STATUSLINE, status)
|
||||
val intent = Intent(ACTION_NEW_EXTERNAL_STATUSLINE)
|
||||
intent.putExtras(bundle)
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
|
||||
mainApp.sendBroadcast(intent, null)
|
||||
}
|
||||
|
||||
private fun buildStatusString(profile: Profile): String {
|
||||
var status = ""
|
||||
if (configBuilderPlugin.activePump == null) return ""
|
||||
val loopPlugin = LoopPlugin.getPlugin()
|
||||
if (!loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
status += resourceHelper.gs(R.string.disabledloop) + "\n"
|
||||
lastLoopStatus = false
|
||||
} else if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
lastLoopStatus = true
|
||||
}
|
||||
//Temp basal
|
||||
val treatmentsInterface: TreatmentsInterface = TreatmentsPlugin.getPlugin()
|
||||
val activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis())
|
||||
if (activeTemp != null) {
|
||||
status += activeTemp.toStringShort() + " "
|
||||
}
|
||||
//IOB
|
||||
treatmentsInterface.updateTotalIOBTreatments()
|
||||
val bolusIob = treatmentsInterface.lastCalculationTreatments.round()
|
||||
treatmentsInterface.updateTotalIOBTempBasals()
|
||||
val basalIob = treatmentsInterface.lastCalculationTempBasals.round()
|
||||
status += DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U"
|
||||
if (sp.getBoolean(R.string.key_xdripstatus_detailediob, true)) {
|
||||
status += ("("
|
||||
+ DecimalFormatter.to2Decimal(bolusIob.iob) + "|"
|
||||
+ DecimalFormatter.to2Decimal(basalIob.basaliob) + ")")
|
||||
}
|
||||
if (!sp.getBoolean(R.string.key_xdripstatus_showbgi, false)) {
|
||||
return status
|
||||
}
|
||||
val bgi = -(bolusIob.activity + basalIob.activity) * 5 * Profile.fromMgdlToUnits(profile.isfMgdl, profileFunction.getUnits())
|
||||
status += " " + (if (bgi >= 0) "+" else "") + DecimalFormatter.to2Decimal(bgi)
|
||||
status += " " + IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "StatusLinePlugin").generateCOBString()
|
||||
return status
|
||||
}
|
||||
}
|
|
@ -1,216 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.xdripStatusline;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.events.EventAppInitialized;
|
||||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by adrian on 17/11/16.
|
||||
*/
|
||||
|
||||
public class StatuslinePlugin extends PluginBase {
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
private static StatuslinePlugin statuslinePlugin;
|
||||
|
||||
public static StatuslinePlugin getPlugin() {
|
||||
return statuslinePlugin;
|
||||
}
|
||||
|
||||
//broadcast related constants
|
||||
private static final String EXTRA_STATUSLINE = "com.eveningoutpost.dexdrip.Extras.Statusline";
|
||||
private static final String ACTION_NEW_EXTERNAL_STATUSLINE = "com.eveningoutpost.dexdrip.ExternalStatusline";
|
||||
private static final String RECEIVER_PERMISSION = "com.eveningoutpost.dexdrip.permissions.RECEIVE_EXTERNAL_STATUSLINE";
|
||||
|
||||
|
||||
private boolean lastLoopStatus;
|
||||
|
||||
private final Context ctx;
|
||||
private SharedPreferences mPrefs;
|
||||
|
||||
|
||||
public static StatuslinePlugin initPlugin(Context ctx) {
|
||||
if (statuslinePlugin == null) {
|
||||
statuslinePlugin = new StatuslinePlugin(ctx);
|
||||
}
|
||||
|
||||
return statuslinePlugin;
|
||||
}
|
||||
|
||||
public StatuslinePlugin(Context ctx) {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.pluginName(R.string.xdripstatus)
|
||||
.shortName(R.string.xdripstatus_shortname)
|
||||
.neverVisible(true)
|
||||
.preferencesId(R.xml.pref_xdripstatus)
|
||||
.description(R.string.description_xdrip_status_line)
|
||||
);
|
||||
this.ctx = ctx;
|
||||
this.mPrefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventRefreshOverview.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> {
|
||||
if ((lastLoopStatus != LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)))
|
||||
sendStatus();
|
||||
},
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventExtendedBolusChange.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> sendStatus(),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventTempBasalChange.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> sendStatus(),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventTreatmentChange.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> sendStatus(),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventConfigBuilderChange.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> sendStatus(),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventAutosensCalculationFinished.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> sendStatus(),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventPreferenceChange.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> sendStatus(),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventAppInitialized.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> sendStatus(),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
disposable.clear();
|
||||
sendStatus();
|
||||
}
|
||||
|
||||
private void sendStatus() {
|
||||
String status = ""; // sent once on disable
|
||||
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (isEnabled(PluginType.GENERAL) && profile != null) {
|
||||
status = buildStatusString(profile);
|
||||
}
|
||||
|
||||
//sendData
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putString(EXTRA_STATUSLINE, status);
|
||||
Intent intent = new Intent(ACTION_NEW_EXTERNAL_STATUSLINE);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
ctx.sendBroadcast(intent, null);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String buildStatusString(Profile profile) {
|
||||
String status = "";
|
||||
|
||||
if (ConfigBuilderPlugin.getPlugin().getActivePump() == null)
|
||||
return "";
|
||||
|
||||
LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||
|
||||
if (!loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
status += MainApp.gs(R.string.disabledloop) + "\n";
|
||||
lastLoopStatus = false;
|
||||
} else if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
lastLoopStatus = true;
|
||||
}
|
||||
|
||||
//Temp basal
|
||||
TreatmentsInterface treatmentsInterface = TreatmentsPlugin.getPlugin();
|
||||
|
||||
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis());
|
||||
if (activeTemp != null) {
|
||||
status += activeTemp.toStringShort() + " ";
|
||||
}
|
||||
|
||||
//IOB
|
||||
treatmentsInterface.updateTotalIOBTreatments();
|
||||
IobTotal bolusIob = treatmentsInterface.getLastCalculationTreatments().round();
|
||||
treatmentsInterface.updateTotalIOBTempBasals();
|
||||
IobTotal basalIob = treatmentsInterface.getLastCalculationTempBasals().round();
|
||||
status += DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U";
|
||||
|
||||
|
||||
if (mPrefs.getBoolean("xdripstatus_detailediob", true)) {
|
||||
status += "("
|
||||
+ DecimalFormatter.to2Decimal(bolusIob.iob) + "|"
|
||||
+ DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
|
||||
}
|
||||
|
||||
if (!mPrefs.getBoolean("xdripstatus_showbgi", false)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
double bgi = -(bolusIob.activity + basalIob.activity) * 5 * Profile.fromMgdlToUnits(profile.getIsfMgdl(), ProfileFunctions.getSystemUnits());
|
||||
|
||||
status += " " + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to2Decimal(bgi);
|
||||
status += " " + IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "StatuslinePlugin").generateCOBString();
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
|
@ -1687,5 +1687,7 @@
|
|||
<string name="alreadyset">Already set</string>
|
||||
<string name="message">Message</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>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory
|
||||
android:key="DanaRProfile"
|
||||
android:title="@string/danarprofile">
|
||||
<EditTextPreference
|
||||
android:defaultValue="3"
|
||||
android:key="@string/key_danarprofile_dia"
|
||||
android:numeric="decimal"
|
||||
android:dialogMessage="@string/danarprofile_dia_summary"
|
||||
android:title="@string/danarprofile_dia" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="xdripstatus_detailediob"
|
||||
android:key="@string/key_xdripstatus_detailediob"
|
||||
android:title="@string/wear_detailedIOB_title"
|
||||
android:summary="@string/wear_detailedIOB_summary"/>
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="xdripstatus_showbgi"
|
||||
android:key="@string/key_xdripstatus_showbgi"
|
||||
android:title="@string/wear_showbgi_title"
|
||||
android:summary="@string/wear_showbgi_summary"/>
|
||||
</PreferenceCategory>
|
||||
|
|
Loading…
Reference in a new issue