profile helper

This commit is contained in:
Milos Kozak 2020-07-14 16:51:13 +02:00
parent 639e5b8302
commit 24f60ebc65
9 changed files with 495 additions and 106 deletions

View file

@ -68,7 +68,8 @@
<activity android:name=".plugins.general.maintenance.activities.PrefImportListActivity" />
<activity android:name=".historyBrowser.HistoryBrowseActivity" />
<activity android:name=".activities.SurveyActivity" />
<activity android:name=".activities.ProfileHelperActivity" />
<activity android:name=".activities.ProfileHelperActivity"
android:theme="@style/ProfileHelperAppTheme" />
<activity android:name=".activities.StatsActivity" />
<!-- Receive new BG readings from other local apps -->

View file

@ -1,13 +1,27 @@
package info.nightscout.androidaps.activities
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.Menu
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.db.ProfileSwitch
import info.nightscout.androidaps.dialogs.ProfileViewerDialog
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin
import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfileChanged
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.extensions.toVisibility
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.stats.TddCalculator
import kotlinx.android.synthetic.main.activity_profilehelper.*
@ -20,43 +34,157 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
@Inject lateinit var tddCalculator: TddCalculator
@Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var defaultProfile: DefaultProfile
@Inject lateinit var localProfilePlugin: LocalProfilePlugin
@Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var activePlugin: ActivePluginProvider
@Inject lateinit var databaseHelper: DatabaseHelperInterface
enum class ProfileType {
MOTOL_DEFAULT,
CURRENT,
AVAILABLE_PROFILE,
PROFILE_SWITCH
}
var tabSelected = 0
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)
lateinit var profileList: ArrayList<CharSequence>
val profileUsed = arrayOf(0, 0)
lateinit var profileSwitch: List<ProfileSwitch>
val profileSwitchUsed = arrayOf(0, 0)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_profilehelper)
profilehelper_age.setParams(15.0, 1.0, 80.0, 1.0, DecimalFormat("0"), false, null)
profilehelper_weight.setParams(50.0, 5.0, 150.0, 1.0, DecimalFormat("0"), false, null)
profilehelper_tdd.setParams(50.0, 3.0, 200.0, 1.0, DecimalFormat("0"), false, null)
profilehelper_menu1.setOnClickListener {
switchTab(0)
}
profilehelper_menu2.setOnClickListener {
switchTab(1)
}
profilehelper_tdds.text = tddCalculator.stats()
profilehelper_profiletype.setOnClickListener {
PopupMenu(this, profilehelper_profiletype).apply {
menuInflater.inflate(R.menu.menu_profilehelper, menu)
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)
}
true
}
show()
}
}
profilehelper_profile.setOnClickListener {
// Active profile
profileList = activePlugin.activeProfileInterface.profile?.getProfileList() ?: ArrayList()
profilehelper_available_profile_list.setOnClickListener {
PopupMenu(this, profilehelper_available_profile_list).apply {
var order = 0
for (name in profileList) menu.add(Menu.NONE, order, order++, name)
setOnMenuItemClickListener { item ->
profilehelper_available_profile_list.setText(item.title)
profileUsed[tabSelected] = item.itemId
true
}
show()
}
}
// Profile switch
profileSwitch = databaseHelper.getProfileSwitchData(dateUtil._now() - T.months(2).msecs(), true)
profilehelper_profileswitch_list.setOnClickListener {
PopupMenu(this, profilehelper_profileswitch_list).apply {
var order = 0
for (name in profileSwitch) menu.add(Menu.NONE, order, order++, name.customizedName)
setOnMenuItemClickListener { item ->
profilehelper_profileswitch_list.setText(item.title)
profileSwitchUsed[tabSelected] = item.itemId
true
}
show()
}
}
// Default profile
profilehelper_copytolocalprofile.setOnClickListener {
val age = profilehelper_age.value
val weight = profilehelper_weight.value
val tdd = profilehelper_tdd.value
if (age < 1 || age > 120) {
ToastUtils.showToastInUiThread(this, R.string.invalidage)
return@setOnClickListener
defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())?.let { profile ->
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())))
rxBus.send(EventLocalProfileChanged())
})
}
if ((weight < 5 || weight > 150) && tdd == 0.0) {
ToastUtils.showToastInUiThread(this, R.string.invalidweight)
return@setOnClickListener
}
profilehelper_age.setParams(0.0, 1.0, 80.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) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
profilehelper_tdd_row.visibility = (profilehelper_weight.value == 0.0).toVisibility()
}
if ((tdd < 5 || tdd > 150) && weight == 0.0) {
ToastUtils.showToastInUiThread(this, R.string.invalidweight)
return@setOnClickListener
})
profilehelper_tdd.setParams(0.0, 0.0, 200.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) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
profilehelper_weight_row.visibility = (profilehelper_tdd.value == 0.0).toVisibility()
}
profileFunction.getProfile()?.let { runningProfile ->
defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())?.let { profile ->
})
profilehelper_tdds.text = tddCalculator.stats()
// Current profile
profilehelper_current_profile_text.text = profileFunction.getProfileName()
// 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
}
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
}
}
getProfile(age, tdd, weight, 0)?.let { profile0 ->
getProfile(age, tdd, weight, 1)?.let { profile1 ->
ProfileViewerDialog().also { pvd ->
pvd.arguments = Bundle().also {
it.putLong("time", DateUtil.now())
it.putInt("mode", ProfileViewerDialog.Mode.PROFILE_COMPARE.ordinal)
it.putString("customProfile", runningProfile.data.toString())
it.putString("customProfile2", profile.data.toString())
it.putString("customProfileUnits", profile.units)
it.putString("customProfileName", "Age: $age TDD: $tdd Weight: $weight")
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))
}
}.show(supportFragmentManager, "ProfileViewDialog")
return@setOnClickListener
@ -65,5 +193,83 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
ToastUtils.showToastInUiThread(this, R.string.invalidinput)
}
switchTab(0)
}
private fun getProfile(age: Double, tdd: Double, weight: Double, tab: Int): Profile? =
when (typeSelected[tab]) {
ProfileType.MOTOL_DEFAULT -> defaultProfile.profile(age, tdd, weight, 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 =
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.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 switchContent(newContent: ProfileType) {
profilehelper_default_profile.visibility = (newContent == ProfileType.MOTOL_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]
}
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)
}
}
}
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

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M20.964,12.509V2.983l-2.932,2.932c-4.317,-3.412 -9.981,-3.694 -13.245,-0.43c-3.581,3.581 -2.909,10.058 1.5,14.467c0.427,0.427 0.877,0.807 1.338,1.163c-0.548,-0.841 -1.031,-1.781 -1.411,-2.812C4.438,13.481 5.49,8.653 8.565,7.519c1.867,-0.688 4.047,0.152 5.872,1.99l-3,3H20.964z"
android:fillColor="#739BE0"/>
</vector>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -11,85 +12,230 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/profilehelper_age_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:labelFor="@+id/profilehelper_age"
android:text="@string/age"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/profilehelper_age"
android:layout_width="130dp"
android:layout_height="40dp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/profilehelper_weigth_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:labelFor="@+id/profilehelper_weight"
android:text="@string/weight_label"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/profilehelper_weight"
android:layout_width="130dp"
android:layout_height="40dp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/profilehelper_tdd_label"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:labelFor="@+id/profilehelper_weight"
android:text="@string/tdd_total"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/profilehelper_tdd"
android:layout_width="130dp"
android:layout_height="40dp" />
</TableRow>
</TableLayout>
<TextView
android:id="@+id/profilehelper_tdds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
<Button
android:id="@+id/profilehelper_profile"
android:id="@+id/profilehelper_compareprofile"
style="@style/ButtonMediumFontStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_auto_delta"
android:text="@string/comapareprofile" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="@color/defaultbackground"
android:orientation="horizontal">
<TextView
android:id="@+id/profilehelper_menu1"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1"
android:gravity="center"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="1" />
<TextView
android:id="@+id/profilehelper_menu2"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1"
android:gravity="center"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="2" />
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/profiletype"
android:textColorHint="@color/tabBgColorSelected"
app:boxStrokeColor="@color/tabBgColorSelected">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/profilehelper_profiletype"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:clickable="true"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:importantForAutofill="no" />
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:id="@+id/profilehelper_default_profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/profilehelper_age_label"
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" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/profilehelper_age"
android:layout_width="130dp"
android:layout_height="40dp" />
</TableRow>
<TableRow
android:id="@+id/profilehelper_tdd_row"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/profilehelper_tdd_label"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:labelFor="@+id/profilehelper_weight"
android:text="@string/tdd_total"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/profilehelper_tdd"
android:layout_width="130dp"
android:layout_height="40dp" />
</TableRow>
<TableRow
android:id="@+id/profilehelper_weight_row"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/profilehelper_weigth_label"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:labelFor="@+id/profilehelper_weight"
android:text="@string/weight_label"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/profilehelper_weight"
android:layout_width="130dp"
android:layout_height="40dp" />
</TableRow>
</TableLayout>
<TextView
android:id="@+id/profilehelper_tdds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
<Button
android:id="@+id/profilehelper_copytolocalprofile"
style="@style/ButtonMediumFontStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawableStart="@drawable/ic_clone_48"
android:text="@string/clone_label" />
</LinearLayout>
<LinearLayout
android:id="@+id/profilehelper_current_profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/profilehelper_current_profile_text"
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>
<LinearLayout
android:id="@+id/profilehelper_available_profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/selected_profile"
android:textColorHint="@color/white"
app:boxStrokeColor="@color/white">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/profilehelper_available_profile_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:clickable="true"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:importantForAutofill="no" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/profilehelper_profile_switch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/careportal_profileswitch"
android:textColorHint="@color/white"
app:boxStrokeColor="@color/white">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/profilehelper_profileswitch_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:clickable="true"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:importantForAutofill="no" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_default"
android:title="@string/motoldefaultprofile" />
<item
android:id="@+id/menu_current"
android:title="@string/currentprofile" />
<item
android:id="@+id/menu_available"
android:title="@string/availableprofile" />
<item
android:id="@+id/menu_profileswitch"
android:title="@string/careportal_profileswitch" />
</menu>

View file

@ -1465,7 +1465,7 @@
<string name="clone_label">Clone</string>
<string name="saveorresetchangesfirst">Save or reset current changes first</string>
<string name="deletecurrentprofile">Delete current profile?</string>
<string name="copytolocalprofile">Create new local profile from this profile switch?</string>
<string name="copytolocalprofile">Create new local profile from this profile?</string>
<string name="profilenamecontainsdot">Profile name contains dots.\nThis is not supported by NS.\nProfile is not uploaded to NS.</string>
<string name="low_mark_comment">Lower value of in range area (display only)</string>
<string name="high_mark_comment">Higher value of in range area (display only)</string>
@ -1708,7 +1708,13 @@
<string name="omnipod_bolus_failed_uncertain">Unable to verify whether the bolus succeeded. Please verify that your Pod is bolusing or cancel the bolus.</string>
<string name="omnipod_rl_stats">RL Stats</string>
<string name="omnipod_read_pulse_log_short">Pulse Log</string>
<string name="comapareprofile">Compare with current profile</string>
<string name="comapareprofile">Compare profiles</string>
<string name="nav_profilehelper">Profile helper</string>
<string name="motoldefaultprofile">Motol default profile</string>
<string name="currentprofile">Current profile</string>
<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="formatwithweight">Age: %1$.0f Weight: %2$.0f kg</string>
</resources>

View file

@ -83,5 +83,5 @@
<item name="android:dividerHeight">1dp</item>
</style>
<style name="ProfileHelperAppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar"/>
</resources>

View file

@ -130,20 +130,20 @@ class DefaultProfile @Inject constructor(val injector: HasAndroidInjector) {
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].toString()))
basals.put(JSONObject().put("time", time).put("value", b[i].toString()).put("timeAsSeconds", i * 3600))
}
return basals
}
private fun singleValueArray(value: Double, sample: Array<Double>): JSONArray {
val array = JSONArray()
array.put(JSONObject().put("time", "00:00").put("value", value + sample[0]))
array.put(JSONObject().put("time", "06:00").put("value", value + sample[1]))
array.put(JSONObject().put("time", "09:00").put("value", value + sample[2]))
array.put(JSONObject().put("time", "11:00").put("value", value + sample[3]))
array.put(JSONObject().put("time", "14:00").put("value", value + sample[4]))
array.put(JSONObject().put("time", "16:00").put("value", value + sample[5]))
array.put(JSONObject().put("time", "19:00").put("value", value + sample[6]))
array.put(JSONObject().put("time", "00:00").put("value", value + sample[0]).put("timeAsSeconds", 0 * 3600))
array.put(JSONObject().put("time", "06:00").put("value", value + sample[1]).put("timeAsSeconds", 6 * 3600))
array.put(JSONObject().put("time", "09:00").put("value", value + sample[2]).put("timeAsSeconds", 9 * 3600))
array.put(JSONObject().put("time", "11:00").put("value", value + sample[3]).put("timeAsSeconds", 11 * 3600))
array.put(JSONObject().put("time", "14:00").put("value", value + sample[4]).put("timeAsSeconds", 14 * 3600))
array.put(JSONObject().put("time", "16:00").put("value", value + sample[5]).put("timeAsSeconds", 16 * 3600))
array.put(JSONObject().put("time", "19:00").put("value", value + sample[6]).put("timeAsSeconds", 19 * 3600))
return array
}
}

View file

@ -46,6 +46,10 @@
<item name="android:textSize">10sp</item>
</style>
<style name="ButtonMediumFontStyle">
<item name="android:textSize">15sp</item>
</style>
<!-- Buttons from MaterialDateTimePicker -->
<dimen name="mdtp_material_button_height">48dp</dimen>
<dimen name="mdtp_material_button_textsize">14sp</dimen>