simplify :core:interfaces

This commit is contained in:
Milos Kozak 2023-09-18 16:07:53 +02:00
parent 739ba4902b
commit 79135e6262
97 changed files with 315 additions and 239 deletions

View file

@ -1,6 +1,6 @@
package info.nightscout.interfaces
enum class ApsMode() {
enum class ApsMode {
OPEN,
CLOSED,
LGS,

View file

@ -1,22 +1,11 @@
package info.nightscout.interfaces.aps
import org.json.JSONObject
class AutosensResult {
data class AutosensResult(
//default values to show when autosens algorithm is not called
var ratio = 1.0
var carbsAbsorbed = 0.0
var sensResult = "autosens not available"
var pastSensitivity = ""
var ratioLimit = ""
fun json(): JSONObject = JSONObject()
.put("ratio", ratio)
.put("ratioLimit", ratioLimit)
.put("pastSensitivity", pastSensitivity)
.put("sensResult", sensResult)
.put("ratio", ratio)
override fun toString(): String = json().toString()
}
var ratio: Double = 1.0,
var carbsAbsorbed: Double = 0.0,
var sensResult: String = "autosens not available",
var pastSensitivity: String = "",
var ratioLimit: String = ""
)

View file

@ -1,9 +1,6 @@
package info.nightscout.interfaces.nsclient
import info.nightscout.interfaces.utils.JsonHelper
import org.json.JSONObject
class NSAlarm(private var data: JSONObject) {
interface NSAlarm {
/*
{
"level":2,
@ -18,24 +15,11 @@ class NSAlarm(private var data: JSONObject) {
}
*/
fun level(): Int =
JsonHelper.safeGetInt(data, "level", 0)
fun group(): String =
JsonHelper.safeGetString(data, "group", "N/A")
fun title(): String =
JsonHelper.safeGetString(data, "title", "N/A")
fun message(): String =
JsonHelper.safeGetString(data, "message", "N/A")
fun low() :Boolean =
JsonHelper.safeGetString(data, "eventName", "") == "low"
fun high() :Boolean =
JsonHelper.safeGetString(data, "eventName", "") == "high"
fun timeago() :Boolean =
JsonHelper.safeGetString(data, "eventName", "") == "timeago"
fun level(): Int
fun group(): String
fun title(): String
fun message(): String
fun low(): Boolean
fun high(): Boolean
fun timeago(): Boolean
}

View file

@ -1,32 +1,19 @@
package info.nightscout.interfaces.nsclient
import info.nightscout.interfaces.utils.JsonHelper
import org.json.JSONObject
/**
*
* {"mgdl":105,"mills":1455136282375,"device":"xDrip-BluetoothWixel","direction":"Flat","filtered":98272,"unfiltered":98272,"noise":1,"rssi":100}
*/
@Suppress("SpellCheckingInspection")
class NSSgv(val data: JSONObject) {
interface NSSgv {
val mgdl: Int?
get() = JsonHelper.safeGetIntAllowNull(data, "mgdl")
val filtered: Int?
get() = JsonHelper.safeGetIntAllowNull(data, "filtered")
val unfiltered: Int?
get() = JsonHelper.safeGetIntAllowNull(data, "unfiltered")
val noise: Int?
get() = JsonHelper.safeGetIntAllowNull(data, "noise")
val rssi: Int?
get() = JsonHelper.safeGetIntAllowNull(data, "rssi")
val mills: Long?
get() = JsonHelper.safeGetLongAllowNull(data, "mills")
val device: String?
get() = JsonHelper.safeGetStringAllowNull(data, "device", null)
val direction: String?
get() = JsonHelper.safeGetStringAllowNull(data, "direction", null)
val id: String?
get() = JsonHelper.safeGetStringAllowNull(data, "_id", null)
}

View file

@ -1,12 +1,12 @@
package info.nightscout.core.extensions
import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.ProfileSwitch
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.PureProfile
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import org.json.JSONObject

View file

@ -8,6 +8,7 @@ import info.nightscout.core.extensions.highValueToUnitsToString
import info.nightscout.core.extensions.lowValueToUnitsToString
import info.nightscout.core.iob.round
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.extensions.formatColor
import info.nightscout.database.entities.BolusCalculatorResult
import info.nightscout.database.entities.OfflineEvent
@ -36,7 +37,6 @@ import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.interfaces.utils.Round
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventRefreshOverview

View file

@ -4,6 +4,8 @@ import dagger.android.HasAndroidInjector
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.extensions.valueToUnits
import info.nightscout.core.iob.round
import info.nightscout.core.utils.JsonHelper.safeGetInt
import info.nightscout.core.utils.JsonHelper.safeGetString
import info.nightscout.core.utils.MidnightUtils
import info.nightscout.database.ValueWrapper
import info.nightscout.interfaces.aps.Loop
@ -14,8 +16,6 @@ import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.utils.JsonHelper.safeGetInt
import info.nightscout.interfaces.utils.JsonHelper.safeGetString
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil

View file

@ -1,6 +1,5 @@
package info.nightscout.core.utils
import info.nightscout.interfaces.utils.JsonHelper
import org.json.JSONObject
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test

View file

@ -1,4 +1,4 @@
package info.nightscout.interfaces.utils
package info.nightscout.core.utils
import android.text.Html
import android.text.SpannableStringBuilder

View file

@ -1,4 +1,4 @@
package info.nightscout.interfaces.utils
package info.nightscout.core.utils
import org.json.JSONException
import org.json.JSONObject

View file

@ -4,12 +4,12 @@ import androidx.collection.ArrayMap
import dagger.android.HasAndroidInjector
import info.nightscout.core.extensions.pureProfileFromJson
import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.utils.JsonHelper
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileStore
import info.nightscout.interfaces.profile.PureProfile
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -12,6 +12,7 @@ import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.extensions.getCustomizedName
import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.ValueWrapper
import info.nightscout.database.entities.EffectiveProfileSwitch
@ -58,7 +59,6 @@ import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.queue.CustomCommand
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventDismissBolusProgressIfRunning

View file

@ -3,6 +3,7 @@ package info.nightscout.implementation.userEntry
import android.text.Spanned
import dagger.Reusable
import info.nightscout.core.main.R
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.ColorGroup
@ -13,7 +14,6 @@ import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.Translator
import info.nightscout.interfaces.userEntry.UserEntryPresentationHelper
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.shared.interfaces.ProfileUtil
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil

View file

@ -34,24 +34,22 @@ import info.nightscout.androidaps.plugins.pump.insight.exceptions.InsightExcepti
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.AppLayerErrorException;
import info.nightscout.androidaps.plugins.pump.insight.utils.AlertUtils;
import info.nightscout.androidaps.plugins.pump.insight.utils.ExceptionTranslator;
import info.nightscout.interfaces.utils.HtmlHelper;
import info.nightscout.core.utils.HtmlHelper;
import info.nightscout.rx.logging.AAPSLogger;
import info.nightscout.rx.logging.LTag;
import info.nightscout.shared.interfaces.ResourceHelper;
public class InsightAlertService extends DaggerService implements InsightConnectionService.StateCallback {
private static final int NOTIFICATION_ID = 31345;
private final LocalBinder localBinder = new LocalBinder();
private final Object $alertLock = new Object[0];
private final MutableLiveData<Alert> alertLiveData = new MutableLiveData<>();
@Inject AAPSLogger aapsLogger;
@Inject ResourceHelper rh;
@Inject AlertUtils alertUtils;
private static final int NOTIFICATION_ID = 31345;
private final LocalBinder localBinder = new LocalBinder();
private boolean connectionRequested;
private final Object $alertLock = new Object[0];
private Alert alert = null;
private final MutableLiveData<Alert> alertLiveData = new MutableLiveData<>();
private Thread thread;
private Vibrator vibrator;
private boolean vibrating;
@ -100,7 +98,7 @@ public class InsightAlertService extends DaggerService implements InsightConnect
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
vibrator = ((VibratorManager)(getSystemService(Context.VIBRATOR_MANAGER_SERVICE))).getDefaultVibrator();
vibrator = ((VibratorManager) (getSystemService(Context.VIBRATOR_MANAGER_SERVICE))).getDefaultVibrator();
} else {
vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
}

View file

@ -22,7 +22,7 @@ import info.nightscout.androidaps.plugins.pump.insight.InsightAlertService;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.Alert;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.AlertStatus;
import info.nightscout.androidaps.plugins.pump.insight.utils.AlertUtils;
import info.nightscout.interfaces.utils.HtmlHelper;
import info.nightscout.core.utils.HtmlHelper;
public class InsightAlertActivity extends DaggerAppCompatActivity {

View file

@ -5,6 +5,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.core.extensions.convertedToAbsolute
import info.nightscout.core.extensions.convertedToPercent
import info.nightscout.core.ui.R
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.interfaces.aps.APSResult
import info.nightscout.interfaces.constraints.Constraint
@ -15,7 +16,6 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -15,6 +15,7 @@ import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle
import dagger.android.support.DaggerFragment
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.aps.AutosensResult
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.plugins.aps.databinding.OpenapsFragmentBinding
import info.nightscout.plugins.aps.events.EventOpenAPSUpdateGui
@ -30,6 +31,7 @@ import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
import org.json.JSONArray
import org.json.JSONException
import org.json.JSONObject
import javax.inject.Inject
class OpenAPSFragment : DaggerFragment(), MenuProvider {
@ -64,7 +66,11 @@ class OpenAPSFragment : DaggerFragment(), MenuProvider {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.swipeRefresh.setColorSchemeColors(rh.gac(context, android.R.attr.colorPrimaryDark), rh.gac(context, android.R.attr.colorPrimary), rh.gac(context,com.google.android.material.R.attr.colorSecondary))
binding.swipeRefresh.setColorSchemeColors(
rh.gac(context, android.R.attr.colorPrimaryDark),
rh.gac(context, android.R.attr.colorPrimary),
rh.gac(context, com.google.android.material.R.attr.colorSecondary)
)
binding.swipeRefresh.setOnRefreshListener {
binding.lastrun.text = rh.gs(R.string.executing)
handler.post { activePlugin.activeAPS.invoke("OpenAPS swipe refresh", false) }
@ -156,6 +162,13 @@ class OpenAPSFragment : DaggerFragment(), MenuProvider {
binding.swipeRefresh.isRefreshing = false
}
private fun AutosensResult.json(): JSONObject = JSONObject()
.put("ratio", ratio)
.put("ratioLimit", ratioLimit)
.put("pastSensitivity", pastSensitivity)
.put("sensResult", sensResult)
.put("ratio", ratio)
@Synchronized
private fun resetGUI(text: String) {
if (_binding == null) return

View file

@ -14,11 +14,11 @@ import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle
import dagger.android.support.DaggerFragment
import info.nightscout.core.pump.toHtml
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.plugins.aps.R
import info.nightscout.plugins.aps.databinding.LoopFragmentBinding
import info.nightscout.plugins.aps.loop.events.EventLoopSetLastRunGui

View file

@ -1,7 +1,7 @@
package info.nightscout.plugins.aps.utils
import android.text.Spanned
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.rx.logging.AAPSLogger
import org.json.JSONArray
import org.json.JSONException

View file

@ -7,6 +7,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.core.extensions.pureProfileFromJson
import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.ui.elements.WeekDay
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.interfaces.Config
@ -20,7 +21,6 @@ import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Instantiator
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.plugins.aps.R
import info.nightscout.plugins.general.autotune.data.ATProfile
@ -153,7 +153,7 @@ class AutotunePlugin @Inject constructor(
}
autotuneFS.exportPumpProfile(pumpProfile)
if (calcDays==0) {
if (calcDays == 0) {
result = rh.gs(info.nightscout.core.ui.R.string.autotune_error_more_days)
log(result)
calculationRunning = false
@ -429,7 +429,7 @@ class AutotunePlugin @Inject constructor(
}
}
for (i in days.weekdays.indices)
days.weekdays[i] = JsonHelper.safeGetBoolean(json, WeekDay.DayOfWeek.values()[i].name,true)
days.weekdays[i] = JsonHelper.safeGetBoolean(json, WeekDay.DayOfWeek.values()[i].name, true)
result = JsonHelper.safeGetString(json, "result", "")
updateButtonVisibility = JsonHelper.safeGetInt(json, "updateButtonVisibility")
lastRunSuccess = true
@ -438,17 +438,17 @@ class AutotunePlugin @Inject constructor(
}
}
fun calcDays(daysBack:Int): Int {
var endTime = MidnightTime.calc(dateUtil.now()) + autotuneStartHour * 60 * 60 * 1000L
if (endTime > dateUtil.now()) endTime -= T.days(1).msecs() // Check if 4 AM is before now
val startTime = endTime - daysBack * T.days(1).msecs()
var result = 0
for (i in 0 until daysBack) {
if (days.isSet(startTime + i * T.days(1).msecs()))
result++
}
return result
fun calcDays(daysBack: Int): Int {
var endTime = MidnightTime.calc(dateUtil.now()) + autotuneStartHour * 60 * 60 * 1000L
if (endTime > dateUtil.now()) endTime -= T.days(1).msecs() // Check if 4 AM is before now
val startTime = endTime - daysBack * T.days(1).msecs()
var result = 0
for (i in 0 until daysBack) {
if (days.isSet(startTime + i * T.days(1).msecs()))
result++
}
return result
}
private fun log(message: String) {
atLog("[Plugin] $message")

View file

@ -2,12 +2,12 @@ package info.nightscout.plugins.aps.loop
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.JsonHelper.safeGetDouble
import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.interfaces.aps.APSResult
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.utils.JsonHelper.safeGetDouble
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach

View file

@ -1,11 +1,11 @@
package info.nightscout.plugins.general.autotune
import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.data.Block
import info.nightscout.database.entities.data.TargetBlock
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.PureProfile
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.general.autotune.data.ATProfile
import info.nightscout.plugins.general.autotune.data.PreppedGlucose
import info.nightscout.shared.utils.DateUtil

View file

@ -2,6 +2,7 @@ package info.nightscout.plugins.general.autotune
import info.nightscout.core.extensions.shiftBlock
import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.Carbs
import info.nightscout.database.entities.GlucoseValue
@ -12,7 +13,6 @@ import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.profile.PureProfile
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.general.autotune.data.PreppedGlucose
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP

View file

@ -32,6 +32,7 @@ import info.nightscout.automation.events.EventAutomationUpdateGui
import info.nightscout.automation.triggers.TriggerConnector
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.ActionModeHelper
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources
@ -39,7 +40,6 @@ import info.nightscout.interfaces.dragHelpers.ItemTouchHelperAdapter
import info.nightscout.interfaces.dragHelpers.OnStartDragListener
import info.nightscout.interfaces.dragHelpers.SimpleItemTouchHelperCallback
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.extensions.toVisibility
@ -104,17 +104,17 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener, MenuProvider {
override fun onMenuItemSelected(item: MenuItem): Boolean =
if (actionHelper.onOptionsItemSelected(item)) true
else when (item.itemId) {
ID_MENU_RUN -> {
ID_MENU_RUN -> {
Thread { automationPlugin.processActions() }.start()
true
}
ID_MENU_ADD -> {
ID_MENU_ADD -> {
add()
true
}
else -> super.onContextItemSelected(item)
else -> super.onContextItemSelected(item)
}
@SuppressLint("NotifyDataSetChanged")

View file

@ -8,11 +8,11 @@ import info.nightscout.automation.R
import info.nightscout.automation.elements.InputString
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.ui.TimerUtil
import info.nightscout.core.utils.JsonHelper
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.automation.ui.TimerUtil
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject

View file

@ -9,6 +9,7 @@ import info.nightscout.automation.elements.InputString
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.core.extensions.fromConstant
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.ValueWithUnit
@ -18,7 +19,6 @@ import info.nightscout.interfaces.iob.GlucoseStatusProvider
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil

View file

@ -7,6 +7,7 @@ import info.nightscout.automation.R
import info.nightscout.automation.elements.InputDuration
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit
@ -14,7 +15,6 @@ import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventRefreshOverview
import org.json.JSONObject

View file

@ -8,12 +8,12 @@ import info.nightscout.automation.elements.InputString
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertTherapyEventAnnouncementTransaction
import info.nightscout.interfaces.notifications.NotificationUserMessage
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventRefreshOverview
import io.reactivex.rxjava3.disposables.CompositeDisposable

View file

@ -7,6 +7,7 @@ import info.nightscout.automation.R
import info.nightscout.automation.elements.InputProfileName
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit
@ -15,7 +16,6 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject

View file

@ -10,6 +10,7 @@ import info.nightscout.automation.elements.InputPercent
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.triggers.TriggerProfilePercent
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit
@ -17,7 +18,6 @@ import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import org.json.JSONObject
import javax.inject.Inject

View file

@ -9,12 +9,12 @@ import info.nightscout.automation.elements.InputWeekDay
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.core.ui.elements.WeekDay
import info.nightscout.core.utils.JsonHelper
import info.nightscout.interfaces.autotune.Autotune
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
@ -89,7 +89,7 @@ class ActionRunAutotune(injector: HasAndroidInjector) : Action(injector) {
override fun fromJSON(data: String): Action {
val o = JSONObject(data)
for (i in days.weekdays.indices)
days.weekdays[i] = JsonHelper.safeGetBoolean(o, WeekDay.DayOfWeek.values()[i].name,true)
days.weekdays[i] = JsonHelper.safeGetBoolean(o, WeekDay.DayOfWeek.values()[i].name, true)
inputProfileName.value = JsonHelper.safeGetString(o, "profileToTune", "")
defaultValue = JsonHelper.safeGetInt(o, "tunedays")
if (defaultValue == 0)

View file

@ -6,10 +6,10 @@ import info.nightscout.automation.R
import info.nightscout.automation.elements.InputString
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.core.utils.JsonHelper
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.smsCommunicator.SmsCommunicator
import info.nightscout.interfaces.utils.JsonHelper
import org.json.JSONObject
import javax.inject.Inject

View file

@ -11,6 +11,8 @@ import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.triggers.TriggerTempTarget
import info.nightscout.core.extensions.friendlyDescription
import info.nightscout.core.utils.JsonHelper
import info.nightscout.core.utils.JsonHelper.safeGetDouble
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Sources
@ -24,8 +26,6 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.JsonHelper.safeGetDouble
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ProfileUtil
import info.nightscout.shared.utils.DateUtil

View file

@ -9,8 +9,8 @@ import info.nightscout.automation.elements.InputDouble
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.interfaces.utils.JsonHelper.safeGetDouble
import info.nightscout.interfaces.utils.JsonHelper.safeGetString
import info.nightscout.core.utils.JsonHelper.safeGetDouble
import info.nightscout.core.utils.JsonHelper.safeGetString
import info.nightscout.rx.logging.LTag
import org.json.JSONObject
import java.text.DecimalFormat

View file

@ -16,7 +16,7 @@ import info.nightscout.automation.elements.InputDropdownMenu
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.core.utils.JsonHelper
import info.nightscout.rx.events.EventBTChange
import info.nightscout.rx.logging.LTag
import org.json.JSONObject

View file

@ -9,9 +9,9 @@ import info.nightscout.automation.elements.InputBg
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.utils.JsonHelper
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import org.json.JSONObject

View file

@ -9,10 +9,10 @@ import info.nightscout.automation.elements.InputDuration
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.utils.JsonHelper
import info.nightscout.core.utils.JsonHelper.safeGetString
import info.nightscout.database.ValueWrapper
import info.nightscout.database.entities.Bolus
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.JsonHelper.safeGetString
import info.nightscout.rx.logging.LTag
import org.json.JSONObject

View file

@ -9,8 +9,8 @@ import info.nightscout.automation.elements.InputDouble
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.JsonHelper.safeGetDouble
import info.nightscout.core.utils.JsonHelper
import info.nightscout.core.utils.JsonHelper.safeGetDouble
import info.nightscout.rx.logging.LTag
import org.json.JSONObject
import java.text.DecimalFormat

View file

@ -12,7 +12,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.automation.R
import info.nightscout.automation.dialogs.ChooseOperationDialog
import info.nightscout.core.ui.elements.VerticalTextView
import info.nightscout.interfaces.utils.JsonHelper.safeGetString
import info.nightscout.core.utils.JsonHelper.safeGetString
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper
import org.json.JSONArray

View file

@ -10,9 +10,9 @@ import info.nightscout.automation.elements.InputDelta.DeltaType
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.utils.JsonHelper
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import org.json.JSONObject
import java.text.DecimalFormat

View file

@ -10,7 +10,7 @@ import info.nightscout.automation.elements.InputDouble
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.core.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import org.json.JSONObject
import java.text.DecimalFormat

View file

@ -9,7 +9,7 @@ import info.nightscout.automation.elements.InputInsulin
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.core.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import org.json.JSONObject

View file

@ -12,7 +12,7 @@ import info.nightscout.automation.elements.InputString
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.core.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import org.json.JSONObject
import java.text.DecimalFormat

View file

@ -10,7 +10,7 @@ import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.profile.ProfileSealed
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.core.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import org.json.JSONObject

View file

@ -9,8 +9,8 @@ import info.nightscout.automation.elements.InputDuration
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.interfaces.utils.JsonHelper.safeGetInt
import info.nightscout.interfaces.utils.JsonHelper.safeGetString
import info.nightscout.core.utils.JsonHelper.safeGetInt
import info.nightscout.core.utils.JsonHelper.safeGetString
import info.nightscout.rx.logging.LTag
import org.json.JSONObject

View file

@ -9,8 +9,8 @@ import info.nightscout.automation.elements.InputWeekDay
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.ui.elements.WeekDay
import info.nightscout.core.utils.JsonHelper
import info.nightscout.core.utils.MidnightUtils
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.rx.logging.LTag
import org.json.JSONObject

View file

@ -7,8 +7,8 @@ import info.nightscout.automation.R
import info.nightscout.automation.elements.ComparatorExists
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.ValueWrapper
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import org.json.JSONObject

View file

@ -9,10 +9,10 @@ import info.nightscout.automation.elements.InputBg
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.ValueWrapper
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import org.json.JSONObject

View file

@ -7,7 +7,7 @@ import info.nightscout.automation.R
import info.nightscout.automation.elements.InputDateTime
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.core.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.utils.T
import org.json.JSONObject

View file

@ -7,8 +7,8 @@ import info.nightscout.automation.R
import info.nightscout.automation.elements.InputTimeRange
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.utils.JsonHelper.safeGetInt
import info.nightscout.core.utils.MidnightUtils
import info.nightscout.interfaces.utils.JsonHelper.safeGetInt
import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.rx.logging.LTag
import org.json.JSONObject

View file

@ -9,8 +9,8 @@ import info.nightscout.automation.elements.InputString
import info.nightscout.automation.elements.LabelWithElement
import info.nightscout.automation.elements.LayoutBuilder
import info.nightscout.automation.elements.StaticLabel
import info.nightscout.core.utils.JsonHelper
import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.rx.logging.LTag
import org.json.JSONObject
import javax.inject.Inject

View file

@ -12,6 +12,7 @@ import info.nightscout.configuration.databinding.MaintenanceFragmentBinding
import info.nightscout.configuration.maintenance.activities.LogSettingActivity
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources
@ -26,7 +27,6 @@ import info.nightscout.interfaces.protection.ProtectionCheck.Protection.PREFEREN
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.sync.DataSyncSelectorXdrip
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventPreferenceChange

View file

@ -18,13 +18,13 @@ import androidx.recyclerview.widget.LinearSmoothScroller
import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.plugins.constraints.R
import info.nightscout.plugins.constraints.databinding.ObjectivesFragmentBinding
import info.nightscout.plugins.constraints.databinding.ObjectivesItemBinding
@ -100,8 +100,8 @@ class ObjectivesFragment : DaggerFragment() {
.toObservable(EventObjectivesUpdateGui::class.java)
.observeOn(aapsSchedulers.main)
.subscribe({
binding.recyclerview.adapter?.notifyDataSetChanged()
}, fabricPrivacy::logException)
binding.recyclerview.adapter?.notifyDataSetChanged()
}, fabricPrivacy::logException)
}
@Synchronized
@ -224,7 +224,12 @@ class ObjectivesFragment : DaggerFragment() {
val state = TextView(holder.binding.progress.context)
state.setTextColor(rh.gac(context, info.nightscout.core.ui.R.attr.defaultTextColor))
val basicHTML = "<font color=\"%1\$s\"><b>%2\$s</b></font>"
val formattedHTML = String.format(basicHTML, if (task.isCompleted()) rh.gac(context, info.nightscout.core.ui.R.attr.isCompletedColor) else rh.gac(context, info.nightscout.core.ui.R.attr.isNotCompletedColor), task.progress)
val formattedHTML =
String.format(
basicHTML,
if (task.isCompleted()) rh.gac(context, info.nightscout.core.ui.R.attr.isCompletedColor) else rh.gac(context, info.nightscout.core.ui.R.attr.isNotCompletedColor),
task.progress
)
state.text = HtmlHelper.fromHtml(formattedHTML)
state.gravity = Gravity.END
holder.binding.progress.addView(state, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
@ -333,8 +338,10 @@ class ObjectivesFragment : DaggerFragment() {
holder.binding.unstart.setOnClickListener {
activity?.let { activity ->
OKDialog.showConfirmation(activity, rh.gs(info.nightscout.core.ui.R.string.objectives), rh.gs(R.string.doyouwantresetstart), Runnable {
uel.log(Action.OBJECTIVE_UNSTARTED, Sources.Objectives,
ValueWithUnit.SimpleInt(position + 1))
uel.log(
Action.OBJECTIVE_UNSTARTED, Sources.Objectives,
ValueWithUnit.SimpleInt(position + 1)
)
objective.startedOn = 0
scrollToCurrentObjective()
rxBus.send(EventObjectivesUpdateGui())

View file

@ -35,6 +35,7 @@ import info.nightscout.core.ui.UIRunnable
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.elements.SingleClickButton
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.JsonHelper
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.wizard.QuickWizard
import info.nightscout.database.entities.UserEntry.Action
@ -66,7 +67,6 @@ import info.nightscout.interfaces.source.DexcomBoyda
import info.nightscout.interfaces.source.XDripSource
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.TrendCalculator
import info.nightscout.plugins.R
import info.nightscout.plugins.databinding.OverviewFragmentBinding
@ -843,7 +843,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
if (it.value.originalPercentage != 100 || it.value.originalTimeshift != 0L || it.value.originalDuration != 0L)
info.nightscout.core.ui.R.attr.ribbonWarningColor
else info.nightscout.core.ui.R.attr.ribbonDefaultColor
} else info.nightscout.core.ui.R.attr.ribbonDefaultColor
} else info.nightscout.core.ui.R.attr.ribbonDefaultColor
} ?: info.nightscout.core.ui.R.attr.ribbonCriticalColor
val profileTextColor = profile?.let {
@ -1095,7 +1095,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
}
binding.infoLayout.sensitivity.text =
lastAutosensData?.let {
lastAutosensData?.let {
String.format(Locale.ENGLISH, "%.0f%%", it.autosensResult.ratio * 100)
} ?: ""
// Show variable sensitivity

View file

@ -5,10 +5,10 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import dagger.android.support.DaggerFragment
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.smsCommunicator.Sms
import info.nightscout.interfaces.smsCommunicator.SmsCommunicator
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.plugins.databinding.SmscommunicatorFragmentBinding
import info.nightscout.plugins.general.smsCommunicator.events.EventSmsCommunicatorUpdateGui
import info.nightscout.rx.AapsSchedulers

View file

@ -8,6 +8,7 @@ import info.nightscout.core.extensions.pureProfileFromJson
import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.JsonHelper
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
@ -24,7 +25,6 @@ import info.nightscout.interfaces.profile.ProfileStore
import info.nightscout.interfaces.profile.PureProfile
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.R
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventLocalProfileChanged

View file

@ -4,6 +4,7 @@ import android.content.Context
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.JsonHelper.safeGetString
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository
@ -14,7 +15,6 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.source.BgSource
import info.nightscout.interfaces.utils.JsonHelper.safeGetString
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -0,0 +1,42 @@
package info.nightscout.plugins.sync.nsShared
import info.nightscout.core.utils.JsonHelper
import info.nightscout.interfaces.nsclient.NSAlarm
import org.json.JSONObject
class NSAlarmObject(private var data: JSONObject) : NSAlarm {
/*
{
"level":2,
"title":"Urgent HIGH",
"message":"BG Now: 5.2 -0.1 → mmol\/L\nRaw BG: 5 mmol\/L Čistý\nBG 15m: 5 mmol\/L\nIOB: 0.00U\nCOB: 0g",
"eventName":"high",
"plugin":{"name":"simplealarms","label":"Simple Alarms","pluginType":"notification","enabled":true},
"pushoverSound":"persistent",
"debug":{"lastSGV":5.2,"thresholds":{"bgHigh":80,"bgTargetTop":75,"bgTargetBottom":72,"bgLow":70}},
"group":"default",
"key":"simplealarms_2"
}
*/
override fun level(): Int =
JsonHelper.safeGetInt(data, "level", 0)
override fun group(): String =
JsonHelper.safeGetString(data, "group", "N/A")
override fun title(): String =
JsonHelper.safeGetString(data, "title", "N/A")
override fun message(): String =
JsonHelper.safeGetString(data, "message", "N/A")
override fun low(): Boolean =
JsonHelper.safeGetString(data, "eventName", "") == "low"
override fun high(): Boolean =
JsonHelper.safeGetString(data, "eventName", "") == "high"
override fun timeago(): Boolean =
JsonHelper.safeGetString(data, "eventName", "") == "timeago"
}

View file

@ -18,6 +18,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.UserEntry
import info.nightscout.interfaces.Config
@ -26,7 +27,6 @@ import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginFragment
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.plugins.sync.R
import info.nightscout.plugins.sync.databinding.NsClientFragmentBinding
import info.nightscout.plugins.sync.databinding.NsClientLogItemBinding
@ -235,6 +235,7 @@ class NSClientFragment : DaggerFragment(), MenuProvider, PluginFragment {
private fun updateLog() {
_binding?.recyclerview?.swapAdapter(RecyclerViewAdapter(nsClientPlugin?.listLog ?: arrayListOf()), true)
}
private inner class RecyclerViewAdapter(private var logList: List<EventNSClientNewLog>) : RecyclerView.Adapter<RecyclerViewAdapter.NsClientLogViewHolder>() {
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): NsClientLogViewHolder =

View file

@ -0,0 +1,33 @@
package info.nightscout.plugins.sync.nsShared
import info.nightscout.core.utils.JsonHelper
import info.nightscout.interfaces.nsclient.NSSgv
import org.json.JSONObject
/**
*
* {"mgdl":105,"mills":1455136282375,"device":"xDrip-BluetoothWixel","direction":"Flat","filtered":98272,"unfiltered":98272,"noise":1,"rssi":100}
*/
@Suppress("SpellCheckingInspection")
class NSSgvObject(val data: JSONObject) : NSSgv {
override val mgdl: Int?
get() = JsonHelper.safeGetIntAllowNull(data, "mgdl")
override val filtered: Int?
get() = JsonHelper.safeGetIntAllowNull(data, "filtered")
override val unfiltered: Int?
get() = JsonHelper.safeGetIntAllowNull(data, "unfiltered")
override val noise: Int?
get() = JsonHelper.safeGetIntAllowNull(data, "noise")
override val rssi: Int?
get() = JsonHelper.safeGetIntAllowNull(data, "rssi")
override val mills: Long?
get() = JsonHelper.safeGetLongAllowNull(data, "mills")
override val device: String?
get() = JsonHelper.safeGetStringAllowNull(data, "device", null)
override val direction: String?
get() = JsonHelper.safeGetStringAllowNull(data, "direction", null)
override val id: String?
get() = JsonHelper.safeGetStringAllowNull(data, "_id", null)
}

View file

@ -1,19 +1,18 @@
package info.nightscout.plugins.sync.nsShared
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.Food
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.transactions.TransactionGlucoseValue
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.nsclient.NSSgv
import info.nightscout.interfaces.nsclient.StoreDataForDb
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.Instantiator
import info.nightscout.interfaces.profile.ProfileSource
import info.nightscout.interfaces.source.NSClientSource
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.sync.R
import info.nightscout.plugins.sync.nsclient.extensions.fromJson
import info.nightscout.plugins.sync.nsclientV3.extensions.toBolus
@ -70,7 +69,7 @@ class NsIncomingDataProcessor @Inject constructor(
) {
private fun toGv(jsonObject: JSONObject): TransactionGlucoseValue? {
val sgv = NSSgv(jsonObject)
val sgv = NSSgvObject(jsonObject)
return TransactionGlucoseValue(
timestamp = sgv.mills ?: return null,
value = sgv.mgdl?.toDouble() ?: return null,

View file

@ -1,12 +1,12 @@
package info.nightscout.plugins.sync.nsclient
import info.nightscout.core.utils.JsonHelper
import info.nightscout.core.utils.waitMillis
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.source.NSClientSource
import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.sync.R
import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGuiQueue
import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGuiStatus

View file

@ -1,11 +1,11 @@
package info.nightscout.plugins.sync.nsclient.data
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.JsonHelper
import info.nightscout.interfaces.Config
import info.nightscout.sdk.interfaces.RunningConfiguration
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.sdk.interfaces.RunningConfiguration
import info.nightscout.sdk.localmodel.devicestatus.NSDeviceStatus
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil

View file

@ -1,6 +1,6 @@
package info.nightscout.plugins.sync.nsclient.data
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.core.utils.JsonHelper
import org.json.JSONObject
class NSMbg(val json: JSONObject) {

View file

@ -5,6 +5,7 @@ package info.nightscout.plugins.sync.nsclient.data
import android.content.Context
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.interfaces.Config
@ -13,7 +14,6 @@ import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.nsclient.NSSettingsStatus
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.sync.R
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventDismissNotification

View file

@ -2,12 +2,12 @@ package info.nightscout.plugins.sync.nsclient.data
import android.text.Spanned
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.JsonHelper
import info.nightscout.interfaces.aps.APSResult
import info.nightscout.interfaces.nsclient.NSSettingsStatus
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
import info.nightscout.interfaces.profile.Instantiator
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.Round
import info.nightscout.plugins.sync.R
import info.nightscout.shared.interfaces.ResourceHelper
@ -46,30 +46,30 @@ class ProcessedDeviceStatusDataImpl @Inject constructor(
// test warning level
val level = when {
pumpData.clock + nsSettingsStatus.extendedPumpSettings("urgentClock") * 60 * 1000L < dateUtil.now() -> ProcessedDeviceStatusData.Levels.URGENT
pumpData.reservoir < nsSettingsStatus.extendedPumpSettings("urgentRes") -> ProcessedDeviceStatusData.Levels.URGENT
pumpData.isPercent && pumpData.percent < nsSettingsStatus.extendedPumpSettings("urgentBattP") -> ProcessedDeviceStatusData.Levels.URGENT
!pumpData.isPercent && pumpData.voltage > 0 && pumpData.voltage < nsSettingsStatus.extendedPumpSettings("urgentBattV") -> ProcessedDeviceStatusData.Levels.URGENT
pumpData.clock + nsSettingsStatus.extendedPumpSettings("warnClock") * 60 * 1000L < dateUtil.now() -> ProcessedDeviceStatusData.Levels.WARN
pumpData.reservoir < nsSettingsStatus.extendedPumpSettings("warnRes") -> ProcessedDeviceStatusData.Levels.WARN
pumpData.isPercent && pumpData.percent < nsSettingsStatus.extendedPumpSettings("warnBattP") -> ProcessedDeviceStatusData.Levels.WARN
!pumpData.isPercent && pumpData.voltage > 0 && pumpData.voltage < nsSettingsStatus.extendedPumpSettings("warnBattV") -> ProcessedDeviceStatusData.Levels.WARN
else -> ProcessedDeviceStatusData.Levels.INFO
}
string.append("<span style=\"color:${level.toColor()}\">")
// val insulinUnit = rh.gs(info.nightscout.core.ui.R.string.insulin_unit_shortname)
pumpData.clock + nsSettingsStatus.extendedPumpSettings("urgentClock") * 60 * 1000L < dateUtil.now() -> ProcessedDeviceStatusData.Levels.URGENT
pumpData.reservoir < nsSettingsStatus.extendedPumpSettings("urgentRes") -> ProcessedDeviceStatusData.Levels.URGENT
pumpData.isPercent && pumpData.percent < nsSettingsStatus.extendedPumpSettings("urgentBattP") -> ProcessedDeviceStatusData.Levels.URGENT
!pumpData.isPercent && pumpData.voltage > 0 && pumpData.voltage < nsSettingsStatus.extendedPumpSettings("urgentBattV") -> ProcessedDeviceStatusData.Levels.URGENT
pumpData.clock + nsSettingsStatus.extendedPumpSettings("warnClock") * 60 * 1000L < dateUtil.now() -> ProcessedDeviceStatusData.Levels.WARN
pumpData.reservoir < nsSettingsStatus.extendedPumpSettings("warnRes") -> ProcessedDeviceStatusData.Levels.WARN
pumpData.isPercent && pumpData.percent < nsSettingsStatus.extendedPumpSettings("warnBattP") -> ProcessedDeviceStatusData.Levels.WARN
!pumpData.isPercent && pumpData.voltage > 0 && pumpData.voltage < nsSettingsStatus.extendedPumpSettings("warnBattV") -> ProcessedDeviceStatusData.Levels.WARN
else -> ProcessedDeviceStatusData.Levels.INFO
}
string.append("<span style=\"color:${level.toColor()}\">")
// val insulinUnit = rh.gs(info.nightscout.core.ui.R.string.insulin_unit_shortname)
// val fields = nsSettingsStatus.pumpExtendedSettingsFields()
// Removed here. Same value is in StatusLights
// if (pumpData.reservoirDisplayOverride != "") string.append(pumpData.reservoirDisplayOverride).append("$insulinUnit ")
// else if (fields.contains("reservoir")) string.append(pumpData.reservoir.toInt()).append("$insulinUnit ")
if (pumpData.isPercent) string.append(pumpData.percent).append("% ")
if (!pumpData.isPercent && pumpData.voltage > 0) string.append(Round.roundTo(pumpData.voltage, 0.001)).append(" ")
string.append(dateUtil.minAgo(rh, pumpData.clock)).append(" ")
string.append(pumpData.status).append(" ")
//string.append(device).append(" ")
string.append("</span>") // color
return HtmlHelper.fromHtml(string.toString())
}
// if (pumpData.reservoirDisplayOverride != "") string.append(pumpData.reservoirDisplayOverride).append("$insulinUnit ")
// else if (fields.contains("reservoir")) string.append(pumpData.reservoir.toInt()).append("$insulinUnit ")
if (pumpData.isPercent) string.append(pumpData.percent).append("% ")
if (!pumpData.isPercent && pumpData.voltage > 0) string.append(Round.roundTo(pumpData.voltage, 0.001)).append(" ")
string.append(dateUtil.minAgo(rh, pumpData.clock)).append(" ")
string.append(pumpData.status).append(" ")
//string.append(device).append(" ")
string.append("</span>") // color
return HtmlHelper.fromHtml(string.toString())
}
override val extendedPumpStatus: Spanned get() = pumpData?.extended ?: HtmlHelper.fromHtml("")
override val extendedOpenApsStatus: Spanned
@ -101,9 +101,11 @@ class ProcessedDeviceStatusDataImpl @Inject constructor(
// test warning level
val level = when {
openAPSData.clockSuggested + T.mins(sp.getLong(info.nightscout.core.utils.R.string.key_ns_alarm_urgent_stale_data_value, 31)).msecs() < dateUtil.now() -> ProcessedDeviceStatusData.Levels.URGENT
openAPSData.clockSuggested + T.mins(sp.getLong(info.nightscout.core.utils.R.string.key_ns_alarm_stale_data_value, 16)).msecs() < dateUtil.now() -> ProcessedDeviceStatusData.Levels.WARN
else -> ProcessedDeviceStatusData.Levels.INFO
openAPSData.clockSuggested + T.mins(sp.getLong(info.nightscout.core.utils.R.string.key_ns_alarm_urgent_stale_data_value, 31))
.msecs() < dateUtil.now() -> ProcessedDeviceStatusData.Levels.URGENT
openAPSData.clockSuggested + T.mins(sp.getLong(info.nightscout.core.utils.R.string.key_ns_alarm_stale_data_value, 16)).msecs() < dateUtil.now() -> ProcessedDeviceStatusData.Levels.WARN
else -> ProcessedDeviceStatusData.Levels.INFO
}
string.append("<span style=\"color:${level.toColor()}\">")
if (openAPSData.clockSuggested != 0L) string.append(dateUtil.minAgo(rh, openAPSData.clockSuggested)).append(" ")
@ -116,9 +118,10 @@ class ProcessedDeviceStatusDataImpl @Inject constructor(
override fun getAPSResult(injector: HasAndroidInjector): APSResult =
instantiator.provideAPSResultObject().also {
it.json = openAPSData.suggested
it.date = openAPSData.clockSuggested
}
it.json = openAPSData.suggested
it.date = openAPSData.clockSuggested
}
override val uploaderStatus: String
get() {
val iterator: Iterator<*> = uploaderMap.entries.iterator()

View file

@ -2,8 +2,8 @@ package info.nightscout.plugins.sync.nsclient.extensions
import com.google.gson.Gson
import com.google.gson.JsonSyntaxException
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.BolusCalculatorResult
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.shared.interfaces.ProfileUtil
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject

View file

@ -1,8 +1,8 @@
package info.nightscout.plugins.sync.nsclient.extensions
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject

View file

@ -1,9 +1,9 @@
package info.nightscout.plugins.sync.nsclient.extensions
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.Carbs
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject

View file

@ -2,10 +2,10 @@ package info.nightscout.plugins.sync.nsclient.extensions
import info.nightscout.core.extensions.pureProfileFromJson
import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.EffectiveProfileSwitch
import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject

View file

@ -1,10 +1,10 @@
package info.nightscout.plugins.sync.nsclient.extensions
import info.nightscout.core.extensions.toTemporaryBasal
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.ExtendedBolus
import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import org.json.JSONObject

View file

@ -1,7 +1,7 @@
package info.nightscout.plugins.sync.nsclient.extensions
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.Food
import info.nightscout.interfaces.utils.JsonHelper
import org.json.JSONObject
fun Food.Companion.fromJson(jsonObject: JSONObject): Food? {

View file

@ -1,8 +1,8 @@
package info.nightscout.plugins.sync.nsclient.extensions
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.OfflineEvent
import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import org.json.JSONObject

View file

@ -4,12 +4,12 @@ import info.nightscout.core.extensions.fromConstant
import info.nightscout.core.extensions.getCustomizedName
import info.nightscout.core.extensions.pureProfileFromJson
import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.ProfileSwitch
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import org.json.JSONObject

View file

@ -1,11 +1,11 @@
package info.nightscout.plugins.sync.nsclient.extensions
import info.nightscout.core.extensions.convertedToAbsolute
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.database.entities.TemporaryBasal.Type.Companion.fromString
import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import org.json.JSONObject

View file

@ -1,9 +1,9 @@
package info.nightscout.plugins.sync.nsclient.extensions
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.shared.interfaces.ProfileUtil
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T

View file

@ -1,9 +1,9 @@
package info.nightscout.plugins.sync.nsclient.extensions
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.sync.nsclient.data.NSMbg
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T

View file

@ -17,18 +17,18 @@ import com.google.gson.JsonDeserializer
import dagger.android.DaggerService
import dagger.android.HasAndroidInjector
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.utils.JsonHelper.safeGetString
import info.nightscout.core.utils.JsonHelper.safeGetStringAllowNull
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.nsclient.NSAlarm
import info.nightscout.interfaces.nsclient.NSSettingsStatus
import info.nightscout.interfaces.nsclient.StoreDataForDb
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.JsonHelper.safeGetString
import info.nightscout.interfaces.utils.JsonHelper.safeGetStringAllowNull
import info.nightscout.plugins.sync.R
import info.nightscout.plugins.sync.nsShared.NSAlarmObject
import info.nightscout.plugins.sync.nsShared.NsIncomingDataProcessor
import info.nightscout.plugins.sync.nsShared.events.EventConnectivityOptionChanged
import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus
@ -638,7 +638,7 @@ import javax.inject.Inject
private fun handleAnnouncement(announcement: JSONObject) {
val defaultVal = config.NSCLIENT
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_announcements, defaultVal)) {
val nsAlarm = NSAlarm(announcement)
val nsAlarm = NSAlarmObject(announcement)
uiInteraction.addNotificationWithAction(injector, nsAlarm)
rxBus.send(EventNSClientNewLog("◄ ANNOUNCEMENT", safeGetString(announcement, "message", "received")))
aapsLogger.debug(LTag.NSCLIENT, announcement.toString())
@ -650,7 +650,7 @@ import javax.inject.Inject
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_alarms, defaultVal)) {
val snoozedTo = sp.getLong(rh.gs(info.nightscout.core.utils.R.string.key_snoozed_to) + alarm.optString("level"), 0L)
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
val nsAlarm = NSAlarm(alarm)
val nsAlarm = NSAlarmObject(alarm)
uiInteraction.addNotificationWithAction(injector, nsAlarm)
}
rxBus.send(EventNSClientNewLog("◄ ALARM", safeGetString(alarm, "message", "received")))
@ -663,7 +663,7 @@ import javax.inject.Inject
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_alarms, defaultVal)) {
val snoozedTo = sp.getLong(rh.gs(info.nightscout.core.utils.R.string.key_snoozed_to) + alarm.optString("level"), 0L)
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
val nsAlarm = NSAlarm(alarm)
val nsAlarm = NSAlarmObject(alarm)
uiInteraction.addNotificationWithAction(injector, nsAlarm)
}
rxBus.send(EventNSClientNewLog("◄ URGENTALARM", safeGetString(alarm, "message", "received")))

View file

@ -3,6 +3,7 @@ package info.nightscout.plugins.sync.nsclient.workers
import android.content.Context
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import info.nightscout.core.utils.JsonHelper
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.Bolus
@ -20,7 +21,6 @@ import info.nightscout.interfaces.Config
import info.nightscout.interfaces.nsclient.StoreDataForDb
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.VirtualPump
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.sync.R
import info.nightscout.plugins.sync.nsclient.extensions.extendedBolusFromJson
import info.nightscout.plugins.sync.nsclient.extensions.fromJson

View file

@ -1,6 +1,7 @@
package info.nightscout.plugins.sync.nsclientV3
import info.nightscout.annotations.OpenForTesting
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.nsclient.StoreDataForDb
@ -8,7 +9,6 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.source.NSClientSource
import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.sync.R
import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGuiQueue
import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGuiStatus

View file

@ -35,6 +35,7 @@ import info.nightscout.interfaces.sync.Sync
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.plugins.sync.R
import info.nightscout.plugins.sync.nsShared.NSAlarmObject
import info.nightscout.plugins.sync.nsShared.NSClientFragment
import info.nightscout.plugins.sync.nsShared.NsIncomingDataProcessor
import info.nightscout.plugins.sync.nsShared.events.EventConnectivityOptionChanged
@ -525,7 +526,7 @@ class NSClientV3Plugin @Inject constructor(
rxBus.send(EventNSClientNewLog("◄ ANNOUNCEMENT", data.optString("message")))
aapsLogger.debug(LTag.NSCLIENT, data.toString())
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_announcements, config.NSCLIENT))
uiInteraction.addNotificationWithAction(injector, NSAlarm(data))
uiInteraction.addNotificationWithAction(injector, NSAlarmObject(data))
}
private val onAlarm = Emitter.Listener { args ->
@ -548,7 +549,7 @@ class NSClientV3Plugin @Inject constructor(
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_alarms, config.NSCLIENT)) {
val snoozedTo = sp.getLong(rh.gs(info.nightscout.core.utils.R.string.key_snoozed_to) + data.optString("level"), 0L)
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo)
uiInteraction.addNotificationWithAction(injector, NSAlarm(data))
uiInteraction.addNotificationWithAction(injector, NSAlarmObject(data))
}
}
@ -559,7 +560,7 @@ class NSClientV3Plugin @Inject constructor(
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_alarms, config.NSCLIENT)) {
val snoozedTo = sp.getLong(rh.gs(info.nightscout.core.utils.R.string.key_snoozed_to) + data.optString("level"), 0L)
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo)
uiInteraction.addNotificationWithAction(injector, NSAlarm(data))
uiInteraction.addNotificationWithAction(injector, NSAlarmObject(data))
}
}

View file

@ -3,10 +3,10 @@ package info.nightscout.plugins.sync.nsclientV3.workers
import android.content.Context
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import info.nightscout.core.utils.JsonHelper
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.interfaces.sync.NsClient
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.sync.nsShared.NsIncomingDataProcessor
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
import info.nightscout.rx.bus.RxBus

View file

@ -5,6 +5,7 @@ import android.text.Spanned
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.plugin.PluginBase
@ -13,7 +14,6 @@ import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.sync.Sync
import info.nightscout.interfaces.sync.Tidepool
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.plugins.sync.R
import info.nightscout.plugins.sync.nsShared.events.EventConnectivityOptionChanged
import info.nightscout.plugins.sync.nsclient.ReceiverDelegate

View file

@ -1,13 +1,13 @@
package info.nightscout.plugins.sync.xdrip
import dagger.Lazy
import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.interfaces.sync.DataSyncSelectorXdrip
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.sync.R
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag

View file

@ -15,6 +15,7 @@ import info.nightscout.core.extensions.toStringShort
import info.nightscout.core.iob.generateCOBString
import info.nightscout.core.iob.round
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
@ -31,7 +32,6 @@ import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.interfaces.sync.Sync
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.plugins.sync.R
import info.nightscout.plugins.sync.nsclient.extensions.toJson
import info.nightscout.plugins.sync.xdrip.events.EventXdripUpdateGUI

View file

@ -7,6 +7,7 @@ import android.view.ViewGroup
import com.google.common.base.Joiner
import dagger.android.HasAndroidInjector
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit
@ -14,7 +15,6 @@ import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.iob.GlucoseStatusProvider
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.shared.interfaces.ProfileUtil
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.ui.databinding.DialogCalibrationBinding

View file

@ -10,6 +10,7 @@ import android.view.ViewGroup
import com.google.common.base.Joiner
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.extensions.formatColor
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.entities.UserEntry.Action
@ -35,7 +36,6 @@ import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ProfileUtil
import info.nightscout.shared.interfaces.ResourceHelper
@ -278,7 +278,12 @@ class CarbsDialog : DialogFragmentWithDate() {
if (duration > 0)
actions.add(rh.gs(info.nightscout.core.ui.R.string.duration) + ": " + duration + rh.gs(info.nightscout.shared.R.string.shorthour))
if (carbsAfterConstraints > 0) {
actions.add(rh.gs(info.nightscout.core.ui.R.string.carbs) + ": " + "<font color='" + rh.gac(context, info.nightscout.core.ui.R.attr.carbsColor) + "'>" + rh.gs(info.nightscout.core.main.R.string.format_carbs, carbsAfterConstraints) + "</font>")
actions.add(
rh.gs(info.nightscout.core.ui.R.string.carbs) + ": " + "<font color='" + rh.gac(
context,
info.nightscout.core.ui.R.attr.carbsColor
) + "'>" + rh.gs(info.nightscout.core.main.R.string.format_carbs, carbsAfterConstraints) + "</font>"
)
if (carbsAfterConstraints != carbs)
actions.add("<font color='" + rh.gac(context, info.nightscout.core.ui.R.attr.warningColor) + "'>" + rh.gs(R.string.carbs_constraint_applied) + "</font>")
}

View file

@ -12,6 +12,7 @@ import com.google.common.base.Joiner
import dagger.android.HasAndroidInjector
import info.nightscout.core.extensions.fromConstant
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.ValueWithUnit
@ -24,7 +25,6 @@ import info.nightscout.interfaces.iob.GlucoseStatusProvider
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ProfileUtil
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -8,6 +8,7 @@ import android.view.ViewGroup
import com.google.common.base.Joiner
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.extensions.formatColor
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.ValueWithUnit
@ -19,7 +20,6 @@ import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.SafeParse
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -8,6 +8,7 @@ import android.view.ViewGroup
import com.google.common.base.Joiner
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.extensions.formatColor
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.UserEntry
@ -24,7 +25,6 @@ import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.SafeParse
import info.nightscout.shared.interfaces.ResourceHelper
@ -125,7 +125,9 @@ class FillDialog : DialogFragmentWithDate() {
.formatColor(context, rh, info.nightscout.core.ui.R.attr.insulinButtonColor)
)
if (abs(insulinAfterConstraints - insulin) > 0.01)
actions.add(rh.gs(info.nightscout.core.ui.R.string.bolus_constraint_applied_warn, insulin, insulinAfterConstraints).formatColor(context, rh, info.nightscout.core.ui.R.attr.warningColor))
actions.add(
rh.gs(info.nightscout.core.ui.R.string.bolus_constraint_applied_warn, insulin, insulinAfterConstraints).formatColor(context, rh, info.nightscout.core.ui.R.attr.warningColor)
)
}
val siteChange = binding.fillCatheterChange.isChecked
if (siteChange)

View file

@ -10,6 +10,7 @@ import android.view.ViewGroup
import com.google.common.base.Joiner
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.extensions.formatColor
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.entities.UserEntry
@ -35,7 +36,6 @@ import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.SafeParse
import info.nightscout.shared.extensions.toVisibility
@ -204,7 +204,9 @@ class InsulinDialog : DialogFragmentWithDate() {
if (recordOnlyChecked)
actions.add(rh.gs(info.nightscout.core.ui.R.string.bolus_recorded_only).formatColor(context, rh, info.nightscout.core.ui.R.attr.warningColor))
if (abs(insulinAfterConstraints - insulin) > pumpDescription.pumpType.determineCorrectBolusStepSize(insulinAfterConstraints))
actions.add(rh.gs(info.nightscout.core.ui.R.string.bolus_constraint_applied_warn, insulin, insulinAfterConstraints).formatColor(context, rh, info.nightscout.core.ui.R.attr.warningColor))
actions.add(
rh.gs(info.nightscout.core.ui.R.string.bolus_constraint_applied_warn, insulin, insulinAfterConstraints).formatColor(context, rh, info.nightscout.core.ui.R.attr.warningColor)
)
}
val eatingSoonTTDuration = defaultValueHelper.determineEatingSoonTTDuration()
val eatingSoonTT = defaultValueHelper.determineEatingSoonTT()

View file

@ -12,6 +12,7 @@ import com.google.common.base.Joiner
import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.ValueWithUnit
@ -25,7 +26,6 @@ import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.extensions.toVisibility

View file

@ -13,6 +13,7 @@ import info.nightscout.core.extensions.getCustomizedName
import info.nightscout.core.extensions.pureProfileFromJson
import info.nightscout.core.main.R
import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.database.ValueWrapper
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config
@ -22,7 +23,6 @@ import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.extensions.toVisibility
import info.nightscout.shared.interfaces.ProfileUtil

View file

@ -8,6 +8,7 @@ import android.view.ViewGroup
import com.google.common.base.Joiner
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.extensions.formatColor
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.ValueWithUnit
@ -22,7 +23,6 @@ import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.SafeParse
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -10,6 +10,7 @@ import com.google.common.base.Joiner
import com.google.common.collect.Lists
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.database.ValueWrapper
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.entities.UserEntry
@ -24,7 +25,6 @@ import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ProfileUtil
import info.nightscout.shared.interfaces.ResourceHelper
@ -186,31 +186,34 @@ class TempTargetDialog : DialogFragmentWithDate() {
OKDialog.showConfirmation(activity, rh.gs(info.nightscout.core.ui.R.string.temporary_target), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
val units = profileFunction.getUnits()
when (reason) {
rh.gs(info.nightscout.core.ui.R.string.eatingsoon) -> uel.log(
rh.gs(info.nightscout.core.ui.R.string.eatingsoon) -> uel.log(
UserEntry.Action.TT, UserEntry.Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason(
TemporaryTarget.Reason.EATING_SOON
), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration)
)
rh.gs(info.nightscout.core.ui.R.string.activity) -> uel.log(
rh.gs(info.nightscout.core.ui.R.string.activity) -> uel.log(
UserEntry.Action.TT, UserEntry.Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason(
TemporaryTarget.Reason.ACTIVITY
), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration)
)
rh.gs(info.nightscout.core.ui.R.string.hypo) -> uel.log(
rh.gs(info.nightscout.core.ui.R.string.hypo) -> uel.log(
UserEntry.Action.TT, UserEntry.Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason(
TemporaryTarget.Reason.HYPOGLYCEMIA
), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration)
)
rh.gs(info.nightscout.core.ui.R.string.manual) -> uel.log(
rh.gs(info.nightscout.core.ui.R.string.manual) -> uel.log(
UserEntry.Action.TT, UserEntry.Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason(
TemporaryTarget.Reason.CUSTOM
), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration)
)
rh.gs(info.nightscout.core.ui.R.string.stoptemptarget) -> uel.log(UserEntry.Action.CANCEL_TT, UserEntry.Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged })
rh.gs(info.nightscout.core.ui.R.string.stoptemptarget) -> uel.log(
UserEntry.Action.CANCEL_TT,
UserEntry.Sources.TTDialog,
ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged })
}
if (target == 0.0 || duration == 0) {
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(eventTime))

View file

@ -10,6 +10,7 @@ import android.view.ViewGroup
import com.google.common.base.Joiner
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.extensions.formatColor
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.ValueWithUnit
@ -26,7 +27,6 @@ import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.SafeParse
import info.nightscout.shared.interfaces.ResourceHelper
@ -157,8 +157,12 @@ class TreatmentDialog : DialogFragmentWithDate() {
)
}
if (carbsAfterConstraints > 0) {
actions.add(rh.gs(info.nightscout.core.ui.R.string.carbs) + ": " + rh.gs(info.nightscout.core.main.R.string.format_carbs, carbsAfterConstraints).formatColor(context, rh, info.nightscout
.core.ui.R.attr.carbsColor))
actions.add(
rh.gs(info.nightscout.core.ui.R.string.carbs) + ": " + rh.gs(info.nightscout.core.main.R.string.format_carbs, carbsAfterConstraints).formatColor(
context, rh, info.nightscout
.core.ui.R.attr.carbsColor
)
)
if (carbsAfterConstraints != carbs)
actions.add(rh.gs(R.string.carbs_constraint_applied).formatColor(context, rh, info.nightscout.core.ui.R.attr.warningColor))
}

View file

@ -22,6 +22,7 @@ import info.nightscout.core.extensions.valueToUnits
import info.nightscout.core.iob.round
import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.HtmlHelper
import info.nightscout.core.utils.extensions.formatColor
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.wizard.BolusWizard
@ -37,7 +38,6 @@ import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.interfaces.utils.Round
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
@ -515,9 +515,13 @@ class WizardDialog : DaggerDialogFragment() {
}
if (wizard.calculatedTotalInsulin > 0.0 || carbsAfterConstraint > 0.0) {
val insulinText = if (wizard.calculatedTotalInsulin > 0.0) rh.gs(info.nightscout.core.ui.R.string.format_insulin_units, wizard.calculatedTotalInsulin).formatColor(context, rh, info.nightscout.core.ui.R.attr.bolusColor) else ""
val carbsText = if (carbsAfterConstraint > 0.0) rh.gs(info.nightscout.core.main.R.string.format_carbs, carbsAfterConstraint).formatColor(context, rh, info.nightscout.core.ui.R.attr
.carbsColor) else ""
val insulinText =
if (wizard.calculatedTotalInsulin > 0.0) rh.gs(info.nightscout.core.ui.R.string.format_insulin_units, wizard.calculatedTotalInsulin)
.formatColor(context, rh, info.nightscout.core.ui.R.attr.bolusColor) else ""
val carbsText = if (carbsAfterConstraint > 0.0) rh.gs(info.nightscout.core.main.R.string.format_carbs, carbsAfterConstraint).formatColor(
context, rh, info.nightscout.core.ui.R.attr
.carbsColor
) else ""
binding.total.text = HtmlHelper.fromHtml(rh.gs(R.string.result_insulin_carbs, insulinText, carbsText))
binding.okcancel.ok.visibility = View.VISIBLE
} else {