move UserEntryMapper
This commit is contained in:
parent
d50d1bf9c9
commit
07f1168270
|
@ -4,14 +4,13 @@ import android.content.Context
|
||||||
import android.widget.TableRow
|
import android.widget.TableRow
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
|
||||||
|
|
||||||
interface DexcomTIR {
|
interface DexcomTIR {
|
||||||
|
|
||||||
fun calculateSD(): Double
|
fun calculateSD(): Double
|
||||||
fun toHbA1cView(context: Context, rh: ResourceHelper): TextView
|
fun toHbA1cView(context: Context): TextView
|
||||||
fun toSDView(context: Context, rh: ResourceHelper, profileFunction: ProfileFunction): TextView
|
fun toSDView(context: Context, profileFunction: ProfileFunction): TextView
|
||||||
fun toRangeHeaderView(context: Context, rh: ResourceHelper, profileFunction: ProfileFunction): TextView
|
fun toRangeHeaderView(context: Context, profileFunction: ProfileFunction): TextView
|
||||||
fun toTableRowHeader(context: Context, rh: ResourceHelper): TableRow
|
fun toTableRowHeader(context: Context): TableRow
|
||||||
fun toTableRow(context: Context, rh: ResourceHelper): TableRow
|
fun toTableRow(context: Context): TableRow
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package info.nightscout.androidaps.logging
|
package info.nightscout.androidaps.logging
|
||||||
|
|
||||||
import info.nightscout.androidaps.annotations.OpenForTesting
|
import info.nightscout.androidaps.annotations.OpenForTesting
|
||||||
import info.nightscout.database.impl.AppRepository
|
|
||||||
import info.nightscout.database.impl.transactions.UserEntryTransaction
|
|
||||||
import info.nightscout.androidaps.utils.userEntry.UserEntryMapper
|
|
||||||
import info.nightscout.androidaps.utils.userEntry.ValueWithUnitMapper
|
|
||||||
import info.nightscout.database.entities.UserEntry.Action
|
import info.nightscout.database.entities.UserEntry.Action
|
||||||
import info.nightscout.database.entities.UserEntry.Sources
|
import info.nightscout.database.entities.UserEntry.Sources
|
||||||
import info.nightscout.database.entities.ValueWithUnit
|
import info.nightscout.database.entities.ValueWithUnit
|
||||||
|
import info.nightscout.database.impl.AppRepository
|
||||||
|
import info.nightscout.database.impl.transactions.UserEntryTransaction
|
||||||
|
import info.nightscout.interfaces.userEntry.UserEntryMapper
|
||||||
|
import info.nightscout.interfaces.userEntry.ValueWithUnitMapper
|
||||||
import info.nightscout.rx.AapsSchedulers
|
import info.nightscout.rx.AapsSchedulers
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.shared.utils.DateUtil
|
import info.nightscout.shared.utils.DateUtil
|
||||||
|
|
|
@ -40,10 +40,10 @@ class DexcomTirCalculatorImpl @Inject constructor(
|
||||||
TableLayout(context).also { layout ->
|
TableLayout(context).also { layout ->
|
||||||
val tir = calculate()
|
val tir = calculate()
|
||||||
layout.layoutParams = TableLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)
|
layout.layoutParams = TableLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)
|
||||||
layout.addView(tir.toRangeHeaderView(context, rh, profileFunction))
|
layout.addView(tir.toRangeHeaderView(context, profileFunction))
|
||||||
layout.addView(tir.toTableRowHeader(context, rh))
|
layout.addView(tir.toTableRowHeader(context))
|
||||||
layout.addView(tir.toTableRow(context, rh))
|
layout.addView(tir.toTableRow(context))
|
||||||
layout.addView(tir.toSDView(context, rh, profileFunction))
|
layout.addView(tir.toSDView(context, profileFunction))
|
||||||
layout.addView(tir.toHbA1cView(context, rh))
|
layout.addView(tir.toHbA1cView(context))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,7 +13,6 @@ import info.nightscout.implementation.R
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
@ -75,11 +74,11 @@ class DexcomTirImpl : DexcomTIR {
|
||||||
return sqrt(standardDeviation / count)
|
return sqrt(standardDeviation / count)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toHbA1cView(context: Context, rh: ResourceHelper): TextView =
|
override fun toHbA1cView(context: Context): TextView =
|
||||||
TextView(context).apply {
|
TextView(context).apply {
|
||||||
text =
|
text =
|
||||||
if (count == 0) ""
|
if (count == 0) ""
|
||||||
else rh.gs(R.string.hba1c) +
|
else context.getString(R.string.hba1c) +
|
||||||
(10 * (mean() + 46.7) / 28.7).roundToInt() / 10.0 + "%" +
|
(10 * (mean() + 46.7) / 28.7).roundToInt() / 10.0 + "%" +
|
||||||
" (" +
|
" (" +
|
||||||
(((mean() + 46.7) / 28.7 - 2.15) * 10.929).roundToInt() +
|
(((mean() + 46.7) / 28.7 - 2.15) * 10.929).roundToInt() +
|
||||||
|
@ -89,20 +88,20 @@ class DexcomTirImpl : DexcomTIR {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun toSDView(context: Context, rh: ResourceHelper, profileFunction: ProfileFunction): TextView =
|
override fun toSDView(context: Context, profileFunction: ProfileFunction): TextView =
|
||||||
TextView(context).apply {
|
TextView(context).apply {
|
||||||
val sd = calculateSD()
|
val sd = calculateSD()
|
||||||
text = "\n" + rh.gs(R.string.std_deviation, Profile.toUnitsString(sd, sd * Constants.MGDL_TO_MMOLL, profileFunction.getUnits()))
|
text = "\n" + context.getString(R.string.std_deviation, Profile.toUnitsString(sd, sd * Constants.MGDL_TO_MMOLL, profileFunction.getUnits()))
|
||||||
setTypeface(typeface, Typeface.NORMAL)
|
setTypeface(typeface, Typeface.NORMAL)
|
||||||
gravity = Gravity.CENTER_HORIZONTAL
|
gravity = Gravity.CENTER_HORIZONTAL
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toRangeHeaderView(context: Context, rh: ResourceHelper, profileFunction: ProfileFunction): TextView =
|
override fun toRangeHeaderView(context: Context, profileFunction: ProfileFunction): TextView =
|
||||||
TextView(context).apply {
|
TextView(context).apply {
|
||||||
text = StringBuilder()
|
text = StringBuilder()
|
||||||
.append(rh.gs(R.string.detailed_14_days))
|
.append(context.getString(R.string.detailed_14_days))
|
||||||
.append("\n")
|
.append("\n")
|
||||||
.append(rh.gs(R.string.day_tir))
|
.append(context.getString(R.string.day_tir))
|
||||||
.append(" (")
|
.append(" (")
|
||||||
.append(Profile.toUnitsString(0.0, 0.0, profileFunction.getUnits()))
|
.append(Profile.toUnitsString(0.0, 0.0, profileFunction.getUnits()))
|
||||||
.append("-")
|
.append("-")
|
||||||
|
@ -114,7 +113,7 @@ class DexcomTirImpl : DexcomTIR {
|
||||||
.append("-")
|
.append("-")
|
||||||
.append(Profile.toCurrentUnitsString(profileFunction, veryHighTirMgdl))
|
.append(Profile.toCurrentUnitsString(profileFunction, veryHighTirMgdl))
|
||||||
.append("-∞)\n")
|
.append("-∞)\n")
|
||||||
.append(rh.gs(R.string.night_tir))
|
.append(context.getString(R.string.night_tir))
|
||||||
.append(" (")
|
.append(" (")
|
||||||
.append(Profile.toUnitsString(0.0, 0.0, profileFunction.getUnits()))
|
.append(Profile.toUnitsString(0.0, 0.0, profileFunction.getUnits()))
|
||||||
.append("-")
|
.append("-")
|
||||||
|
@ -132,28 +131,28 @@ class DexcomTirImpl : DexcomTIR {
|
||||||
setTextAppearance(android.R.style.TextAppearance_Material_Medium)
|
setTextAppearance(android.R.style.TextAppearance_Material_Medium)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toTableRowHeader(context: Context, rh: ResourceHelper): TableRow =
|
override fun toTableRowHeader(context: Context): TableRow =
|
||||||
TableRow(context).also { header ->
|
TableRow(context).also { header ->
|
||||||
val lp = TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)
|
val lp = TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)
|
||||||
header.layoutParams = TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)
|
header.layoutParams = TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)
|
||||||
header.gravity = Gravity.CENTER_HORIZONTAL
|
header.gravity = Gravity.CENTER_HORIZONTAL
|
||||||
header.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 0; weight = 1f }; text = rh.gs(R.string.veryLow) })
|
header.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 0; weight = 1f }; text = context.getString(R.string.veryLow) })
|
||||||
header.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 1; weight = 1f }; text = rh.gs(R.string.low) })
|
header.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 1; weight = 1f }; text = context.getString(R.string.low) })
|
||||||
header.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 2; weight = 1f }; text = rh.gs(R.string.in_range) })
|
header.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 2; weight = 1f }; text = context.getString(R.string.in_range) })
|
||||||
header.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 3; weight = 1f }; text = rh.gs(R.string.high) })
|
header.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 3; weight = 1f }; text = context.getString(R.string.high) })
|
||||||
header.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 4; weight = 1f }; text = rh.gs(R.string.veryHigh) })
|
header.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 4; weight = 1f }; text = context.getString(R.string.veryHigh) })
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun toTableRow(context: Context, rh: ResourceHelper): TableRow =
|
override fun toTableRow(context: Context): TableRow =
|
||||||
TableRow(context).also { row ->
|
TableRow(context).also { row ->
|
||||||
val lp = TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT, 1f)
|
val lp = TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT, 1f)
|
||||||
row.layoutParams = TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)
|
row.layoutParams = TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)
|
||||||
row.gravity = Gravity.CENTER_HORIZONTAL
|
row.gravity = Gravity.CENTER_HORIZONTAL
|
||||||
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 0 }; text = rh.gs(R.string.formatPercent, veryLowPct()) })
|
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 0 }; text = context.getString(R.string.formatPercent, veryLowPct()) })
|
||||||
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 1 }; text = rh.gs(R.string.formatPercent, lowPct()) })
|
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 1 }; text = context.getString(R.string.formatPercent, lowPct()) })
|
||||||
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 2 }; text = rh.gs(R.string.formatPercent, inRangePct()) })
|
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 2 }; text = context.getString(R.string.formatPercent, inRangePct()) })
|
||||||
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 3 }; text = rh.gs(R.string.formatPercent, highPct()) })
|
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 3 }; text = context.getString(R.string.formatPercent, highPct()) })
|
||||||
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 4 }; text = rh.gs(R.string.formatPercent, veryHighPct()) })
|
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 4 }; text = context.getString(R.string.formatPercent, veryHighPct()) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.utils.userEntry
|
package info.nightscout.interfaces.userEntry
|
||||||
|
|
||||||
import info.nightscout.database.entities.UserEntry
|
import info.nightscout.database.entities.UserEntry
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.utils.userEntry
|
package info.nightscout.interfaces.userEntry
|
||||||
|
|
||||||
import info.nightscout.database.entities.TemporaryTarget
|
import info.nightscout.database.entities.TemporaryTarget
|
||||||
import info.nightscout.database.entities.TherapyEvent
|
import info.nightscout.database.entities.TherapyEvent
|
|
@ -15,8 +15,6 @@ import info.nightscout.androidaps.dana.activities.DanaUserOptionsActivity
|
||||||
import info.nightscout.androidaps.dana.databinding.DanarFragmentBinding
|
import info.nightscout.androidaps.dana.databinding.DanarFragmentBinding
|
||||||
import info.nightscout.androidaps.dana.events.EventDanaRNewStatus
|
import info.nightscout.androidaps.dana.events.EventDanaRNewStatus
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.utils.userEntry.UserEntryMapper.Action
|
|
||||||
import info.nightscout.androidaps.utils.userEntry.UserEntryMapper.Sources
|
|
||||||
import info.nightscout.core.fabric.FabricPrivacy
|
import info.nightscout.core.fabric.FabricPrivacy
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
|
@ -26,6 +24,8 @@ import info.nightscout.interfaces.pump.WarnColors
|
||||||
import info.nightscout.interfaces.pump.defs.PumpType
|
import info.nightscout.interfaces.pump.defs.PumpType
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.interfaces.ui.ActivityNames
|
import info.nightscout.interfaces.ui.ActivityNames
|
||||||
|
import info.nightscout.interfaces.userEntry.UserEntryMapper.Action
|
||||||
|
import info.nightscout.interfaces.userEntry.UserEntryMapper.Sources
|
||||||
import info.nightscout.rx.AapsSchedulers
|
import info.nightscout.rx.AapsSchedulers
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
import info.nightscout.rx.events.EventExtendedBolusChange
|
import info.nightscout.rx.events.EventExtendedBolusChange
|
||||||
|
|
|
@ -10,11 +10,11 @@ import javax.inject.Singleton;
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger;
|
import info.nightscout.androidaps.logging.UserEntryLogger;
|
||||||
import info.nightscout.androidaps.plugins.pump.eopatch.core.api.GetInternalSuspendTime;
|
import info.nightscout.androidaps.plugins.pump.eopatch.core.api.GetInternalSuspendTime;
|
||||||
import info.nightscout.androidaps.plugins.pump.eopatch.core.response.PatchInternalSuspendTimeResponse;
|
import info.nightscout.androidaps.plugins.pump.eopatch.core.response.PatchInternalSuspendTimeResponse;
|
||||||
import info.nightscout.androidaps.utils.userEntry.UserEntryMapper;
|
|
||||||
import info.nightscout.interfaces.pump.PumpSync;
|
import info.nightscout.interfaces.pump.PumpSync;
|
||||||
import info.nightscout.interfaces.queue.Callback;
|
import info.nightscout.interfaces.queue.Callback;
|
||||||
import info.nightscout.interfaces.queue.Command;
|
import info.nightscout.interfaces.queue.Command;
|
||||||
import info.nightscout.interfaces.queue.CommandQueue;
|
import info.nightscout.interfaces.queue.CommandQueue;
|
||||||
|
import info.nightscout.interfaces.userEntry.UserEntryMapper;
|
||||||
import info.nightscout.rx.logging.AAPSLogger;
|
import info.nightscout.rx.logging.AAPSLogger;
|
||||||
import info.nightscout.rx.logging.LTag;
|
import info.nightscout.rx.logging.LTag;
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
|
|
|
@ -16,11 +16,11 @@ import info.nightscout.androidaps.plugins.pump.eopatch.ble.IPreferenceManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.eopatch.core.api.BasalPause;
|
import info.nightscout.androidaps.plugins.pump.eopatch.core.api.BasalPause;
|
||||||
import info.nightscout.androidaps.plugins.pump.eopatch.core.response.PatchBooleanResponse;
|
import info.nightscout.androidaps.plugins.pump.eopatch.core.response.PatchBooleanResponse;
|
||||||
import info.nightscout.androidaps.plugins.pump.eopatch.vo.PatchState;
|
import info.nightscout.androidaps.plugins.pump.eopatch.vo.PatchState;
|
||||||
import info.nightscout.androidaps.utils.userEntry.UserEntryMapper;
|
|
||||||
import info.nightscout.interfaces.pump.PumpSync;
|
import info.nightscout.interfaces.pump.PumpSync;
|
||||||
import info.nightscout.interfaces.queue.Callback;
|
import info.nightscout.interfaces.queue.Callback;
|
||||||
import info.nightscout.interfaces.queue.Command;
|
import info.nightscout.interfaces.queue.Command;
|
||||||
import info.nightscout.interfaces.queue.CommandQueue;
|
import info.nightscout.interfaces.queue.CommandQueue;
|
||||||
|
import info.nightscout.interfaces.userEntry.UserEntryMapper;
|
||||||
import info.nightscout.rx.logging.AAPSLogger;
|
import info.nightscout.rx.logging.AAPSLogger;
|
||||||
import info.nightscout.rx.logging.LTag;
|
import info.nightscout.rx.logging.LTag;
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
|
|
|
@ -11,11 +11,11 @@ import info.nightscout.androidaps.logging.UserEntryLogger;
|
||||||
import info.nightscout.androidaps.plugins.pump.eopatch.ble.IPreferenceManager;
|
import info.nightscout.androidaps.plugins.pump.eopatch.ble.IPreferenceManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.eopatch.core.api.BasalStop;
|
import info.nightscout.androidaps.plugins.pump.eopatch.core.api.BasalStop;
|
||||||
import info.nightscout.androidaps.plugins.pump.eopatch.core.response.BasalStopResponse;
|
import info.nightscout.androidaps.plugins.pump.eopatch.core.response.BasalStopResponse;
|
||||||
import info.nightscout.androidaps.utils.userEntry.UserEntryMapper;
|
|
||||||
import info.nightscout.interfaces.pump.PumpSync;
|
import info.nightscout.interfaces.pump.PumpSync;
|
||||||
import info.nightscout.interfaces.queue.Callback;
|
import info.nightscout.interfaces.queue.Callback;
|
||||||
import info.nightscout.interfaces.queue.Command;
|
import info.nightscout.interfaces.queue.Command;
|
||||||
import info.nightscout.interfaces.queue.CommandQueue;
|
import info.nightscout.interfaces.queue.CommandQueue;
|
||||||
|
import info.nightscout.interfaces.userEntry.UserEntryMapper;
|
||||||
import info.nightscout.rx.logging.AAPSLogger;
|
import info.nightscout.rx.logging.AAPSLogger;
|
||||||
import info.nightscout.rx.logging.LTag;
|
import info.nightscout.rx.logging.LTag;
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
|
|
Loading…
Reference in a new issue