Skip to content

Refactoring Medtrum patch age on pump tab (cleanup code, better l10n)#4326

Merged
MilosKozak merged 5 commits intonightscout:devfrom
vanelsberg:FIX_MTl10n
Nov 19, 2025
Merged

Refactoring Medtrum patch age on pump tab (cleanup code, better l10n)#4326
MilosKozak merged 5 commits intonightscout:devfrom
vanelsberg:FIX_MTl10n

Conversation

@vanelsberg
Copy link
Contributor

Refactoring Medtrum patch age on pump tab:

  • Cleaner code, move logic to dateUtil.timeAgoFullString()
  • Change for Singular/Plural time units
  • @Philoul Adapt strings for l10n
  • Cleanup

vanelsberg added 4 commits November 17, 2025 17:00
Moved age logic to DateUtil.timeAgoFullString()
Refined for better l10n
Update string resources for DateUtil.timeAgoFullString()
Moved ago string logic to DateUtil.timeAgoFullString() for better l10n
@vanelsberg
Copy link
Contributor Author

@MilosKozak Cleaner code + better translatable strings.
AAPS-CI Merges OK with current dev, build tested ok for me.

val daysAgo = T.msecs(milliseconds).days()
val hoursAgo = T.msecs(milliseconds).hours() % 24
val minutesAgo = T.msecs(milliseconds).mins() % 60
val agoString = if (daysAgo > 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Code could be simplified with rh.gq(app.aaps.core.ui.R.plurals.days, daysAgo, daysAgo)
This will manage singular and plural (same for hours and minutes)
dayString and hourString could be merged together with the global string including "ago" ...

<string name="time_ago">ago</string>
<string name="days_ago">%1$.1f days ago</string>
<string name="days_ago_round">%1$.0f days ago</string>
<string name="day_hours_ago">%1$s day %2$s hours ago</string>
Copy link
Contributor

Choose a reason for hiding this comment

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

Here I think only 2 new strings are enough if you use plurals existing keys in core.ui
%1$s ago and %1$s %2$s ago
See comment below

Copy link
Contributor Author

@vanelsberg vanelsberg Nov 18, 2025

Choose a reason for hiding this comment

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

Purpose of this PR is:

  • Fixing l10n translations
  • Generalize and cleanup code (by moving logic outside pump driver)

Changes mentioned are about optimizing use of string resources (optional) in DateUtil.timeAgoFullString().

Copy link
Contributor Author

@vanelsberg vanelsberg Nov 18, 2025

Choose a reason for hiding this comment

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

Updated PR for use of plurals type resource strings

@sonarqubecloud
Copy link

@vanelsberg
Copy link
Contributor Author

vanelsberg commented Nov 18, 2025

@Philoul @jbr7rr: Think this is the final PR now.
Could you have a look/test and confirm so @MilosKozak can merge this PR with current dev?

@MilosKozak Current (updated) PR merges, (AAPS-CI) builds and was tested ok for current dev.

@jbr7rr
Copy link
Contributor

jbr7rr commented Nov 19, 2025

Looks good to me code wise. Like discussed before it would be good to color the patch age (yellow at 3 days, red at 3 days and 8 hours)

@Philoul
Copy link
Contributor

Philoul commented Nov 19, 2025

@jbr7rr

it would be good to color the patch age (yellow at 3 days, red at 3 days and 8 hours)

If we color text, then the thresholds defined for StatusLight (Overview preferences) should be used to be consistant with colors in overview 😉

@vanelsberg
Copy link
Contributor Author

vanelsberg commented Nov 19, 2025

... color the patch age (yellow at 3 days, red at 3 days and 8 hours)

Good idea. Think I can do that too.

As this is new to the original purpose of this PR (l10n & code cleanup),
Could we please close this PR and implement proper age coloring in a new, separate PR?

@MilosKozak MilosKozak merged commit 2d98eda into nightscout:dev Nov 19, 2025
5 of 8 checks passed
@vanelsberg
Copy link
Contributor Author

@MilosKozak Thanks for merging this PR:

@jbr7rr @Philoul Tnx for review input. Will contact you on new PR handling options for coloring the age field.

olorinmaia added a commit to olorinmaia/AndroidAPS that referenced this pull request Nov 19, 2025
MilosKozak added a commit that referenced this pull request Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants