Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Wear: Display New IOB in Wizard Result if IOB is used in calculations #4484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
olorinmaia wants to merge 2 commits into nightscout:dev
base: dev
Choose a base branch
Loading
from olorinmaia:wear_newIob_bolusCalc
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,32 @@ class WizardResultFragment : Fragment() {

builder.addCalculationRow(calculationRowsContainer, WizardCalculationRow(getString(R.string.wizard_result_total), totalInsulin))

// Calculate new IOB if IOB was used in calculation
// New IOB = Total Insulin - Current IOB (because IOB is subtracted in wizard)
// Only calculate if IOB was actually used (totalIob is not NaN means it was included)
val newIob = if (!totalIob.isNaN()) {
totalInsulin - totalIob
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny suggestion-- to an outsider like me, this looks weird. This is addition because totalIob is negative, correct? Maybe comments could be more specific?

Suggested change
totalInsulin - totalIob
totalInsulin - totalIob// totalIob is negative so this is addition

} else {
null // Don't show New IOB if IOB wasn't used in calculation
}

// Setup collapsible calculation details
setupCalculationToggle(view)
setupCalculationToggle(view, newIob)
}

private fun setupCalculationToggle(view: View) {
private fun setupCalculationToggle(view: View, newIob: Double?) {
val calculationHeader = view.findViewById<LinearLayout>(R.id.calculation_header)
val calculationDetails = view.findViewById<LinearLayout>(R.id.calculation_details)
val expandIcon = view.findViewById<TextView>(R.id.expand_icon)
val newIobText = view.findViewById<TextView>(R.id.new_iob_text)

// Set new IOB value - only show if IOB was used in calculation
if (newIob != null) {
newIobText.text = getString(R.string.wizard_result_new_iob, decimalFormat.format(newIob))
newIobText.visibility = View.VISIBLE
} else {
newIobText.visibility = View.GONE
}

var isExpanded = false

Expand Down
12 changes: 11 additions & 1 deletion wear/src/main/res/layout/fragment_wizard_result.xml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@
android:textStyle="bold"
android:textColor="#B0BEC5" />

<TextView
android:id="@+id/new_iob_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New IOB: 0.0 U"
android:textSize="11sp"
android:textColor="#90A4AE"
android:paddingEnd="8dp"
android:paddingStart="8dp" />

<TextView
android:id="@+id/expand_icon"
android:contentDescription="@string/expand_calculation_details"
Expand All @@ -126,7 +136,7 @@
android:text="▼"
android:textSize="12sp"
android:textColor="#B0BEC5"
android:paddingStart="8dp"
android:paddingStart="0dp"
android:paddingEnd="0dp" />
</LinearLayout>

Expand Down
1 change: 1 addition & 0 deletions wear/src/main/res/values/strings.xml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@
<string name="wizard_result_bg_tt">BG (TT: %1$s)</string>
<string name="wizard_result_trend">15\' trend</string>
<string name="wizard_result_iob">IOB</string>
<string name="wizard_result_new_iob">New IOB: %1$s U</string>
<string name="wizard_result_cob">COB (%1$.1f g)</string>
<string name="wizard_result_carbs">Carbs (%1$d g)</string>
<string name="wizard_result_subtotal">Subtotal</string>
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /