diff --git a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt index 3f0155e515..df32da9a79 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt @@ -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 - val profileUsed = arrayOf(0, 0) + private lateinit var profileList: ArrayList + private val profileUsed = arrayOf(0, 0) - lateinit var profileSwitch: List - val profileSwitchUsed = arrayOf(0, 0) + private lateinit var profileSwitch: List + 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)) } - } diff --git a/app/src/main/res/layout/activity_profilehelper.xml b/app/src/main/res/layout/activity_profilehelper.xml index 55f03f9f26..f7cee31409 100644 --- a/app/src/main/res/layout/activity_profilehelper.xml +++ b/app/src/main/res/layout/activity_profilehelper.xml @@ -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"> + + + + + + + + diff --git a/app/src/main/res/menu/menu_profilehelper.xml b/app/src/main/res/menu/menu_profilehelper.xml index ed73bb6f72..ca6e6cb9fc 100644 --- a/app/src/main/res/menu/menu_profilehelper.xml +++ b/app/src/main/res/menu/menu_profilehelper.xml @@ -4,6 +4,9 @@ + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5992070c5d..d1455826e4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1480,6 +1480,7 @@ Survey Invalid age entry Invalid weight entry + Invalid % entry %1$s: Low: %2$02d%% In: %3$02d%% High: %4$02d%%]]> Average TIR @@ -1715,6 +1716,9 @@ Available profile Profile type Age: %1$.0f TDD: %2$.0f U + Age: %1$.0f TDD: %2$.0f U %3$d%% Age: %1$.0f Weight: %2$.0f kg + % of basal + DPV Default profile diff --git a/core/src/main/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfile.kt b/core/src/main/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfile.kt index 4ca60b3fb4..f1a0375d2a 100644 --- a/core/src/main/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfile.kt +++ b/core/src/main/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfile.kt @@ -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) diff --git a/core/src/main/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfileDPV.kt b/core/src/main/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfileDPV.kt new file mode 100644 index 0000000000..18195f9f8a --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfileDPV.kt @@ -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, 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 + } +} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/db/TDD.java b/core/src/main/java/info/nightscout/androidaps/db/TDD.java index 5717abec74..f023c06f7f 100644 --- a/core/src/main/java/info/nightscout/androidaps/db/TDD.java +++ b/core/src/main/java/info/nightscout/androidaps/db/TDD.java @@ -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); } } diff --git a/core/src/main/res/layout/dialog_profileviewer.xml b/core/src/main/res/layout/dialog_profileviewer.xml index feec6a1163..914cc8e71b 100644 --- a/core/src/main/res/layout/dialog_profileviewer.xml +++ b/core/src/main/res/layout/dialog_profileviewer.xml @@ -21,9 +21,10 @@ android:padding="5dp"> diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 93289388fb..8933eefc3d 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -156,8 +156,8 @@ %1$dmin - %1$s: ∑: %2$.2fU Bol: %3$.2fU Bas: %4$.2fU]]> - %1$s: ∑: %2$.2fU Bol: %3$.2fU Bas: %4$.2fU Carbs: %5$.0fg]]> + %1$s: ∑: %2$.2fU Bol: %3$.2fU Bas: %4$.2fU(%5$.0f%%)]]> + %1$s: ∑: %2$.2fU Bol: %3$.2fU Bas: %4$.2fU(%5$.0f%%) Carbs: %6$.0fg]]> BG Check