DPV profile

This commit is contained in:
Milos Kozak 2020-07-16 17:30:04 +02:00
parent 1015158e8b
commit e3cd61cffc
9 changed files with 208 additions and 102 deletions

View file

@ -8,6 +8,7 @@ import android.widget.PopupMenu
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.data.defaultProfile.DefaultProfile
import info.nightscout.androidaps.data.defaultProfile.DefaultProfileDPV
import info.nightscout.androidaps.db.ProfileSwitch
import info.nightscout.androidaps.dialogs.ProfileViewerDialog
import info.nightscout.androidaps.interfaces.ActivePluginProvider
@ -34,6 +35,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
@Inject lateinit var tddCalculator: TddCalculator
@Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var defaultProfile: DefaultProfile
@Inject lateinit var defaultProfileDPV: DefaultProfileDPV
@Inject lateinit var localProfilePlugin: LocalProfilePlugin
@Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var dateUtil: DateUtil
@ -42,33 +44,35 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
enum class ProfileType {
MOTOL_DEFAULT,
DPV_DEFAULT,
CURRENT,
AVAILABLE_PROFILE,
PROFILE_SWITCH
}
var tabSelected = 0
val typeSelected = arrayOf(ProfileType.MOTOL_DEFAULT, ProfileType.CURRENT)
private var tabSelected = 0
private val typeSelected = arrayOf(ProfileType.MOTOL_DEFAULT, ProfileType.CURRENT)
val ageUsed = arrayOf(15.0, 15.0)
val weightUsed = arrayOf(50.0, 50.0)
val tddUsed = arrayOf(50.0, 50.0)
private val ageUsed = arrayOf(15.0, 15.0)
private val weightUsed = arrayOf(0.0, 0.0)
private val tddUsed = arrayOf(0.0, 0.0)
private val pctUsed = arrayOf(32.0, 32.0)
lateinit var profileList: ArrayList<CharSequence>
val profileUsed = arrayOf(0, 0)
private lateinit var profileList: ArrayList<CharSequence>
private val profileUsed = arrayOf(0, 0)
lateinit var profileSwitch: List<ProfileSwitch>
val profileSwitchUsed = arrayOf(0, 0)
private lateinit var profileSwitch: List<ProfileSwitch>
private val profileSwitchUsed = arrayOf(0, 0)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_profilehelper)
profilehelper_menu1.setOnClickListener {
switchTab(0)
switchTab(0, typeSelected[0])
}
profilehelper_menu2.setOnClickListener {
switchTab(1)
switchTab(1, typeSelected[1])
}
profilehelper_profiletype.setOnClickListener {
@ -77,10 +81,11 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
setOnMenuItemClickListener { item ->
profilehelper_profiletype.setText(item.title)
when (item.itemId) {
R.id.menu_default -> switchContent(ProfileType.MOTOL_DEFAULT)
R.id.menu_current -> switchContent(ProfileType.CURRENT)
R.id.menu_available -> switchContent(ProfileType.AVAILABLE_PROFILE)
R.id.menu_profileswitch -> switchContent(ProfileType.PROFILE_SWITCH)
R.id.menu_default -> switchTab(tabSelected, ProfileType.MOTOL_DEFAULT)
R.id.menu_default_dpv -> switchTab(tabSelected, ProfileType.DPV_DEFAULT)
R.id.menu_current -> switchTab(tabSelected, ProfileType.CURRENT)
R.id.menu_available -> switchTab(tabSelected, ProfileType.AVAILABLE_PROFILE)
R.id.menu_profileswitch -> switchTab(tabSelected, ProfileType.PROFILE_SWITCH)
}
true
}
@ -121,20 +126,22 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
}
// Default profile
profilehelper_copytolocalprofile.setOnClickListener {
val age = profilehelper_age.value
val weight = profilehelper_weight.value
val tdd = profilehelper_tdd.value
defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())?.let { profile ->
val age = ageUsed[tabSelected]
val weight = weightUsed[tabSelected]
val tdd = tddUsed[tabSelected]
val pct = pctUsed[tabSelected]
val profile = if (typeSelected[tabSelected] == ProfileType.MOTOL_DEFAULT) defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())
else defaultProfileDPV.profile(age, tdd, pct / 100.0, profileFunction.getUnits())
profile?.let {
OKDialog.showConfirmation(this, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile), Runnable {
localProfilePlugin.addProfile(LocalProfilePlugin.SingleProfile().copyFrom(localProfilePlugin.rawProfile, profile, "DefaultProfile" + dateUtil.dateAndTimeAndSecondsString(dateUtil._now())))
localProfilePlugin.addProfile(LocalProfilePlugin.SingleProfile().copyFrom(localProfilePlugin.rawProfile, it, "DefaultProfile" + dateUtil.dateAndTimeAndSecondsString(dateUtil._now())))
rxBus.send(EventLocalProfileChanged())
})
}
}
profilehelper_age.setParams(0.0, 1.0, 80.0, 1.0, DecimalFormat("0"), false, null)
profilehelper_age.setParams(0.0, 1.0, 18.0, 1.0, DecimalFormat("0"), false, null)
profilehelper_weight.setParams(0.0, 0.0, 150.0, 1.0, DecimalFormat("0"), false, null, object : TextWatcher {
override fun afterTextChanged(s: Editable) {}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
@ -150,6 +157,8 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
}
})
profilehelper_basalpctfromtdd.setParams(32.0, 32.0, 37.0, 1.0, DecimalFormat("0"), false, null)
profilehelper_tdds.text = tddCalculator.stats()
// Current profile
@ -157,26 +166,40 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
// General
profilehelper_compareprofile.setOnClickListener {
val age = profilehelper_age.value
val weight = profilehelper_weight.value
val tdd = profilehelper_tdd.value
if (typeSelected[0] == ProfileType.MOTOL_DEFAULT || typeSelected[1] == ProfileType.MOTOL_DEFAULT) {
if (age < 1 || age > 17) {
ToastUtils.showToastInUiThread(this, R.string.invalidage)
return@setOnClickListener
storeValues()
for (i in 0..1) {
if (typeSelected[i] == ProfileType.MOTOL_DEFAULT) {
if (ageUsed[i] < 1 || ageUsed[i] > 18) {
ToastUtils.showToastInUiThread(this, R.string.invalidage)
return@setOnClickListener
}
if ((weightUsed[i] < 5 || weightUsed[i] > 150) && tddUsed[i] == 0.0) {
ToastUtils.showToastInUiThread(this, R.string.invalidweight)
return@setOnClickListener
}
if ((tddUsed[i] < 5 || tddUsed[i] > 150) && weightUsed[i] == 0.0) {
ToastUtils.showToastInUiThread(this, R.string.invalidweight)
return@setOnClickListener
}
}
if ((weight < 5 || weight > 150) && tdd == 0.0) {
ToastUtils.showToastInUiThread(this, R.string.invalidweight)
return@setOnClickListener
}
if ((tdd < 5 || tdd > 150) && weight == 0.0) {
ToastUtils.showToastInUiThread(this, R.string.invalidweight)
return@setOnClickListener
if (typeSelected[i] == ProfileType.DPV_DEFAULT) {
if (ageUsed[i] < 1 || ageUsed[i] > 18) {
ToastUtils.showToastInUiThread(this, R.string.invalidage)
return@setOnClickListener
}
if (tddUsed[i] < 5 || tddUsed[i] > 150) {
ToastUtils.showToastInUiThread(this, R.string.invalidweight)
return@setOnClickListener
}
if ((pctUsed[i] < 32 || pctUsed[i] > 37)) {
ToastUtils.showToastInUiThread(this, R.string.invalidpct)
return@setOnClickListener
}
}
}
getProfile(age, tdd, weight, 0)?.let { profile0 ->
getProfile(age, tdd, weight, 1)?.let { profile1 ->
getProfile(ageUsed[0], tddUsed[0], weightUsed[0], pctUsed[0] / 100.0, 0)?.let { profile0 ->
getProfile(ageUsed[1], tddUsed[1], weightUsed[1], pctUsed[1] / 100.0, 1)?.let { profile1 ->
ProfileViewerDialog().also { pvd ->
pvd.arguments = Bundle().also {
it.putLong("time", DateUtil.now())
@ -184,7 +207,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
it.putString("customProfile", profile0.data.toString())
it.putString("customProfile2", profile1.data.toString())
it.putString("customProfileUnits", profileFunction.getUnits())
it.putString("customProfileName", getProfileName(age, tdd, weight, 0) + "\n" + getProfileName(age, tdd, weight, 1))
it.putString("customProfileName", getProfileName(ageUsed[0], tddUsed[0], weightUsed[0], pctUsed[0] / 100.0, 0) + "\n" + getProfileName(ageUsed[1], tddUsed[1], weightUsed[1], pctUsed[1] / 100.0, 1))
}
}.show(supportFragmentManager, "ProfileViewDialog")
return@setOnClickListener
@ -193,83 +216,71 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
ToastUtils.showToastInUiThread(this, R.string.invalidinput)
}
switchTab(0)
switchTab(0, typeSelected[0], false)
}
private fun getProfile(age: Double, tdd: Double, weight: Double, tab: Int): Profile? =
private fun getProfile(age: Double, tdd: Double, weight: Double, basalPct: Double, tab: Int): Profile? =
when (typeSelected[tab]) {
ProfileType.MOTOL_DEFAULT -> defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())
ProfileType.DPV_DEFAULT -> defaultProfileDPV.profile(age, tdd, basalPct, profileFunction.getUnits())
ProfileType.CURRENT -> profileFunction.getProfile()?.convertToNonCustomizedProfile()
ProfileType.AVAILABLE_PROFILE -> activePlugin.activeProfileInterface.profile?.getSpecificProfile(profileList[profileUsed[tab]].toString())
ProfileType.PROFILE_SWITCH -> profileSwitch[profileSwitchUsed[tab]].profileObject?.convertToNonCustomizedProfile()
}
private fun getProfileName(age: Double, tdd: Double, weight: Double, tab: Int): String =
private fun getProfileName(age: Double, tdd: Double, weight: Double, basalSumPct: Double, tab: Int): String =
when (typeSelected[tab]) {
ProfileType.MOTOL_DEFAULT -> if (tdd > 0) resourceHelper.gs(R.string.formatwithtdd, age, tdd) else resourceHelper.gs(R.string.formatwithweight, age, weight)
ProfileType.DPV_DEFAULT -> resourceHelper.gs(R.string.formatwittddandpct, age, tdd, (basalSumPct * 100).toInt())
ProfileType.CURRENT -> profileFunction.getProfileName()
ProfileType.AVAILABLE_PROFILE -> profileList[profileUsed[tab]].toString()
ProfileType.PROFILE_SWITCH -> profileSwitch[profileSwitchUsed[tab]].customizedName
}
private fun switchTab(tab: Int) {
setBackgroundColorOnSelected(tab)
when (typeSelected[tab]) {
ProfileType.MOTOL_DEFAULT -> {
ageUsed[tabSelected] = profilehelper_age.value
weightUsed[tabSelected] = profilehelper_weight.value
tddUsed[tabSelected] = profilehelper_tdd.value
profilehelper_profiletype.setText(resourceHelper.gs(R.string.motoldefaultprofile))
}
ProfileType.CURRENT -> {
profilehelper_profiletype.setText(resourceHelper.gs(R.string.currentprofile))
}
ProfileType.AVAILABLE_PROFILE -> {
profilehelper_profiletype.setText(resourceHelper.gs(R.string.availableprofile))
}
ProfileType.PROFILE_SWITCH -> {
profilehelper_profiletype.setText(resourceHelper.gs(R.string.careportal_profileswitch))
}
}
tabSelected = tab
switchContent(typeSelected[tabSelected])
private fun storeValues() {
ageUsed[tabSelected] = profilehelper_age.value
weightUsed[tabSelected] = profilehelper_weight.value
tddUsed[tabSelected] = profilehelper_tdd.value
pctUsed[tabSelected] = profilehelper_basalpctfromtdd.value
}
private fun switchContent(newContent: ProfileType) {
profilehelper_default_profile.visibility = (newContent == ProfileType.MOTOL_DEFAULT).toVisibility()
private fun switchTab(tab: Int, newContent: ProfileType, storeOld: Boolean = true) {
setBackgroundColorOnSelected(tab)
// Store values for selected tab. listBox values are stored on selection change
if (storeOld) storeValues()
tabSelected = tab
typeSelected[tabSelected] = newContent
// show new content
profilehelper_profiletype.setText(
when (typeSelected[tabSelected]) {
ProfileType.MOTOL_DEFAULT -> resourceHelper.gs(R.string.motoldefaultprofile)
ProfileType.DPV_DEFAULT -> resourceHelper.gs(R.string.dpvdefaultprofile)
ProfileType.CURRENT -> resourceHelper.gs(R.string.currentprofile)
ProfileType.AVAILABLE_PROFILE -> resourceHelper.gs(R.string.availableprofile)
ProfileType.PROFILE_SWITCH -> resourceHelper.gs(R.string.careportal_profileswitch)
})
profilehelper_default_profile.visibility = (newContent == ProfileType.MOTOL_DEFAULT || newContent == ProfileType.DPV_DEFAULT).toVisibility()
profilehelper_current_profile.visibility = (newContent == ProfileType.CURRENT).toVisibility()
profilehelper_available_profile.visibility = (newContent == ProfileType.AVAILABLE_PROFILE).toVisibility()
profilehelper_profile_switch.visibility = (newContent == ProfileType.PROFILE_SWITCH).toVisibility()
typeSelected[tabSelected] = newContent
when (newContent) {
ProfileType.MOTOL_DEFAULT -> {
profilehelper_age.value = ageUsed[tabSelected]
profilehelper_weight.value = weightUsed[tabSelected]
profilehelper_tdd.value = tddUsed[tabSelected]
}
// restore selected values
profilehelper_age.value = ageUsed[tabSelected]
profilehelper_weight.value = weightUsed[tabSelected]
profilehelper_tdd.value = tddUsed[tabSelected]
profilehelper_basalpctfromtdd.value = pctUsed[tabSelected]
ProfileType.CURRENT -> {
}
ProfileType.AVAILABLE_PROFILE -> {
if (profileList.size > 0)
profilehelper_available_profile_list.setText(profileList[profileUsed[tabSelected]].toString())
}
ProfileType.PROFILE_SWITCH -> {
if (profileSwitch.size > 0)
profilehelper_profileswitch_list.setText(profileSwitch[profileSwitchUsed[tabSelected]].customizedName)
}
}
profilehelper_basalpctfromtdd_row.visibility = (newContent == ProfileType.DPV_DEFAULT).toVisibility()
if (profileList.isNotEmpty())
profilehelper_available_profile_list.setText(profileList[profileUsed[tabSelected]].toString())
if (profileSwitch.isNotEmpty())
profilehelper_profileswitch_list.setText(profileSwitch[profileSwitchUsed[tabSelected]].customizedName)
}
private fun setBackgroundColorOnSelected(tab: Int) {
profilehelper_menu1.setBackgroundColor(resourceHelper.gc(if (tab == 1) R.color.defaultbackground else R.color.tabBgColorSelected))
profilehelper_menu2.setBackgroundColor(resourceHelper.gc(if (tab == 0) R.color.defaultbackground else R.color.tabBgColorSelected))
}
}

View file

@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".activities.SurveyActivity">
tools:context=".activities.ProfileHelperActivity">
<LinearLayout
android:layout_width="match_parent"
@ -142,6 +142,27 @@
</TableRow>
<TableRow
android:id="@+id/profilehelper_basalpctfromtdd_row"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/profilehelper_basalpctfromtdd_label"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:labelFor="@+id/profilehelper_basalpctfromtdd"
android:text="@string/basalpctfromtdd_label"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/profilehelper_basalpctfromtdd"
android:layout_width="130dp"
android:layout_height="40dp" />
</TableRow>
</TableLayout>
<TextView
@ -172,8 +193,6 @@
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:labelFor="@+id/profilehelper_age"
android:text="@string/age"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
</LinearLayout>

View file

@ -4,6 +4,9 @@
<item
android:id="@+id/menu_default"
android:title="@string/motoldefaultprofile" />
<item
android:id="@+id/menu_default_dpv"
android:title="@string/dpvdefaultprofile" />
<item
android:id="@+id/menu_current"
android:title="@string/currentprofile" />

View file

@ -1480,6 +1480,7 @@
<string name="nav_survey">Survey</string>
<string name="invalidage">Invalid age entry</string>
<string name="invalidweight">Invalid weight entry</string>
<string name="invalidpct">Invalid % entry</string>
<string name="tirformat"><![CDATA[<b>%1$s:</b> Low: <b>%2$02d%%</b> In: <b>%3$02d%%</b> High: <b>%4$02d%%</b>]]></string>
<string name="average">Average</string>
<string name="tir">TIR</string>
@ -1715,6 +1716,9 @@
<string name="availableprofile">Available profile</string>
<string name="profiletype">Profile type</string>
<string name="formatwithtdd">Age: %1$.0f TDD: %2$.0f U</string>
<string name="formatwittddandpct">Age: %1$.0f TDD: %2$.0f U %3$d%%</string>
<string name="formatwithweight">Age: %1$.0f Weight: %2$.0f kg</string>
<string name="basalpctfromtdd_label">% of basal</string>
<string name="dpvdefaultprofile">DPV Default profile</string>
</resources>

View file

@ -33,14 +33,14 @@ class DefaultProfile @Inject constructor(val injector: HasAndroidInjector) {
profile.put("carbratio", singleValueArray(ic, arrayOf(0.0, -3.0, 0.0, -1.0, -3.0, 0.0, -2.0)))
val isf = Round.roundTo(170.0 / _tdd, 0.1)
profile.put("sens", singleValueArrayFromMmolToUnits(isf, arrayOf(0.0, -1.0, -0.0, -0.0, -1.0, 0.0, -1.0),units))
} else if (age >= 12 && age < 18) {
} else if (age >= 12 && age <= 18) {
val _tdd = if (tdd == 0.0) 1.0 * weight else tdd
closest(twelveToSeventeen, _tdd * 0.5)?.let { array -> profile.put("basal", arrayToJson(array)) }
val ic = Round.roundTo(500.0 / _tdd, 1.0)
profile.put("carbratio", singleValueArray(ic, arrayOf(0.0, -1.0, 0.0, 0.0, -1.0, 0.0, -1.0)))
val isf = Round.roundTo(100.0 / _tdd, 0.1)
profile.put("sens", singleValueArrayFromMmolToUnits(isf, arrayOf(0.2, 0.0, 0.2, 0.2, 0.0, 0.2, 0.2),units))
} else if (age >= 18) {
} else if (age > 18) {
return null
}
profile.put("dia", 5.0)

View file

@ -0,0 +1,67 @@
package info.nightscout.androidaps.data.defaultProfile
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.utils.Round
import org.json.JSONArray
import org.json.JSONObject
import java.util.*
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class DefaultProfileDPV @Inject constructor(val injector: HasAndroidInjector) {
var oneToFive = arrayOf(3.97, 3.61, 3.46, 3.70, 3.76, 3.87, 4.18, 4.01, 3.76, 3.54, 3.15, 2.80, 2.86, 3.21, 3.61, 3.97, 4.43, 4.96, 5.10, 5.50, 5.81, 6.14, 5.52, 5.10)
var sixToEleven = arrayOf(4.20, 4.27, 4.41, 4.62, 4.92, 5.09, 5.01, 4.47, 3.89, 3.33, 3.10, 2.91, 2.97, 3.08, 3.36, 3.93, 4.52, 4.76, 4.69, 4.63, 4.63, 4.47, 4.47, 4.31)
var twelveToEighteen = arrayOf(3.47, 3.80, 4.31, 4.95, 5.59, 6.11, 5.89, 5.11, 4.31, 3.78, 3.55, 3.39, 3.35, 3.39, 3.64, 3.97, 4.53, 4.59, 4.50, 4.00, 3.69, 3.39, 3.35, 3.35)
fun profile(age: Double, tdd: Double, basalSumPct: Double, units: String): Profile? {
val basalSum = tdd * basalSumPct
val profile = JSONObject()
if (age >= 1 && age < 6) {
profile.put("basal", arrayToJson(oneToFive, basalSum))
profile.put("carbratio", singleValueArray(0.0))
profile.put("sens", singleValueArrayFromMmolToUnits(0.0, units))
} else if (age >= 6 && age < 12) {
profile.put("basal", arrayToJson(sixToEleven, basalSum))
profile.put("carbratio", singleValueArray(0.0))
profile.put("sens", singleValueArrayFromMmolToUnits(0.0, units))
} else if (age >= 12 && age <= 18) {
profile.put("basal", arrayToJson(twelveToEighteen, basalSum))
profile.put("carbratio", singleValueArray(0.0))
profile.put("sens", singleValueArrayFromMmolToUnits(0.0, units))
} else if (age > 18) {
return null
}
profile.put("dia", 5.0)
profile.put("carbs_hr", 20) // not used
profile.put("delay", 5.0) // not used
profile.put("timezone", TimeZone.getDefault().getID())
profile.put("target_high", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
profile.put("target_low", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
profile.put("units", units)
return Profile(injector, profile, units)
}
private fun arrayToJson(b: Array<Double>, basalSum: Double): JSONArray {
val basals = JSONArray()
for (i in 0..23) {
val time = String.format(Locale.ENGLISH, "%02d:00", i)
basals.put(JSONObject().put("time", time).put("value", (b[i] * basalSum / 100.0).toString()).put("timeAsSeconds", i * 3600))
}
return basals
}
private fun singleValueArray(value: Double): JSONArray {
val array = JSONArray()
array.put(JSONObject().put("time", "00:00").put("value", value).put("timeAsSeconds", 0 * 3600))
return array
}
private fun singleValueArrayFromMmolToUnits(value: Double, units: String): JSONArray {
val array = JSONArray()
array.put(JSONObject().put("time", "00:00").put("value", Profile.fromMmolToUnits(value, units)).put("timeAsSeconds", 0 * 3600))
return array
}
}

View file

@ -59,15 +59,15 @@ public class TDD {
public String toText(ResourceHelper resourceHelper, DateUtil dateUtil, boolean includeCarbs) {
if (includeCarbs)
return resourceHelper.gs(R.string.tddwithcarbsformat, dateUtil.dateStringShort(date), total, bolus, basal, carbs);
return resourceHelper.gs(R.string.tddwithcarbsformat, dateUtil.dateStringShort(date), total, bolus, basal, basal / total * 100, carbs);
else
return resourceHelper.gs(R.string.tddformat, dateUtil.dateStringShort(date), total, bolus, basal);
return resourceHelper.gs(R.string.tddformat, dateUtil.dateStringShort(date), total, bolus, basal, basal / total * 100);
}
public String toText(ResourceHelper resourceHelper, int days, boolean includeCarbs) {
if (includeCarbs)
return resourceHelper.gs(R.string.tddwithcarbsformat, String.format(Locale.getDefault(), "%d ", days) + resourceHelper.gs(R.string.days), total, bolus, basal, carbs);
return resourceHelper.gs(R.string.tddwithcarbsformat, String.format(Locale.getDefault(), "%d ", days) + resourceHelper.gs(R.string.days), total, bolus, basal, basal / total * 100, carbs);
else
return resourceHelper.gs(R.string.tddformat, String.format(Locale.getDefault(), "%d ", days) + resourceHelper.gs(R.string.days), total, bolus, basal);
return resourceHelper.gs(R.string.tddformat, String.format(Locale.getDefault(), "%d ", days) + resourceHelper.gs(R.string.days), total, bolus, basal, basal / total * 100);
}
}

View file

@ -21,9 +21,10 @@
android:padding="5dp">
<ImageView
android:id="@+id/header_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/carbs"
android:layout_centerVertical="true"
android:src="@drawable/ic_home_profile" />
<TextView
@ -31,11 +32,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="@string/carbs"
android:textAlignment="center"
android:layout_toEndOf="@id/header_icon"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>

View file

@ -156,8 +156,8 @@
<string name="mins">%1$dmin</string>
<!-- TDD-->
<string name="tddformat"><![CDATA[<b>%1$s:</b> ∑: <b>%2$.2fU</b> Bol: <b>%3$.2fU</b> Bas: <b>%4$.2fU</b>]]></string>
<string name="tddwithcarbsformat"><![CDATA[<b>%1$s:</b> ∑: <b>%2$.2fU</b> Bol: <b>%3$.2fU</b> Bas: <b>%4$.2fU</b> Carbs: <b>%5$.0fg</b>]]></string>
<string name="tddformat"><![CDATA[<b>%1$s:</b> ∑: <b>%2$.2fU</b> Bol: <b>%3$.2fU</b> Bas: <b>%4$.2fU(%5$.0f%%)</b>]]></string>
<string name="tddwithcarbsformat"><![CDATA[<b>%1$s:</b> ∑: <b>%2$.2fU</b> Bol: <b>%3$.2fU</b> Bas: <b>%4$.2fU(%5$.0f%%)</b> Carbs: <b>%6$.0fg</b>]]></string>
<!-- Translator-->
<string name="careportal_bgcheck">BG Check</string>