Skip to content
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

feature: Live Activity #2191

Open
wants to merge 42 commits into
base: dev
Choose a base branch
from
Open

Conversation

bastiaanv
Copy link

@bastiaanv bastiaanv commented Jul 15, 2024

This PR is an initial/basic version of this Live Activity, without any feature which are spoken of in the Zulipchat.

Look & Feel:

Lock Screen (all iPhone's):

History only History and predictive line Live activity stale (8h limit i.e.)
IMG_2536 IMG_2534 IMG_2535

Dynamic Island (iPhone 14 pro max and higher):

Screenshots are from a iPhone 15 pro max simulator

Dynamic Island minimal Dynamic Island expanded
Simulator Screenshot - iPhone 15 Pro Max - 2024-07-15 at 12 49 36 Simulator Screenshot - iPhone 15 Pro Max - 2024-07-15 at 12 51 14

Settings

Can be found at: Settings -> Alert management -> Live Activity

Root settings Bottom row settings Available datapoints for bottom row
IMG_2537 IMG_2538 IMG_2539

Things to know:

  • The bottom row has a max of 4 items, but less items can be configured for small screen sizes (like the iPhone 13 mini)
  • The bottom row can be configured to the user's wishes. Swap items around, different order etc. The default is: CurrentBG, IOB, COB, UpdatedAt (like in the screenshots)
  • The following events trigger a re-render of the Live Activity:
    • LoopDataManager -> GlucoseStore.glucoseSamplesDidChange
    • LoopDataManager -> CarbStore.carbEntriesDidChange
    • LoopDataManager -> dosing changing
    • NotificationCenter -> UIApplication.willEnterForegroundNotification

@A9qx
Copy link

A9qx commented Jul 16, 2024

Love the draft/prototype! Would love to see this make it into the project down the line I think it looks amazing!

@marionbarker
Copy link
Contributor

Built onto my real phone. Thanks so much for making this available. 👍

@bastienmoulia
Copy link

bastienmoulia commented Jul 24, 2024

Awesome work !

Feat request

  • Is it possible to change the y-axis of the graph in order to be more center on the data like in the app?
    image
    image

  • Maybe the blue area can replace the settings of the upper / lower limit, because it can change in the day. Or maybe the blue area should be displayed with no limit like the other graphs

  • In order to have the graph with full width, the status ring could be in the bottom bar

Bugs found

  • Sometime on iPhone 13 Pro the live activity don't appear. I have to Disable and Enable it in the settings to have it again.

@marionbarker
Copy link
Contributor

I have been using this for several days - I really enjoy having it attached to Loop.

Bug report:

  • Dynamic Island expanded (long press on dynamic island)
    • truncates the display when glucose is in mg/dL and above 99 mg/dL
    • graphic below with 24 hour display disabled (top) and enabled (bottom)

loop-pr-2191-dynamic-island-expanded

Feature requests:

  • see the target range shown on the Look Screen Widget graph
  • see if an override is currently enabled, definitely added to target display on graph, possibly with the override name displayed

ebouchut added a commit to ebouchut/LoopWorkspace that referenced this pull request Jul 24, 2024
@bastiaanv
Copy link
Author

bastiaanv commented Jul 25, 2024

Thanks for all the feedback:

  • The truncate bug has been fixed @marionbarker
  • Also I added the blue area (glucose targets) & the preset to the views, so thank you for the ideas @marionbarker @bastienmoulia .
  • @bastienmoulia I have enabled some extra logging for myown device to research the issue regarding the disappearing of the Live Activity.

Preview

Blue area (glucose target) Preset enabled (without predictive line) Preset enabled (with predictive line)
Simulator Screenshot - iPhone 15 - 2024-07-25 at 20 19 57 Simulator Screenshot - iPhone 15 - 2024-07-25 at 20 07 31 Simulator Screenshot - iPhone 15 - 2024-07-25 at 20 20 08

@marionbarker
Copy link
Contributor

marionbarker commented Jul 25, 2024

Nice upgrade except the override appears confused.

  • This override was active from 11:05 to 1:05 pm (with 2 hours duration), but it shows as being currently active (1:45 pm).
  • I see the same pattern when long-pressing the dynamic island.
  • I updated with the latest commit at 1:21 pm local (after this override had expired).

old-override-shows

  • I added a new override at 1:47 pm that has a duration of 3 hours.
  • I will report back in 20 minutes or so. Long enough to see if the start point is correct
  • And then I will turn it off and see what the plots look like.

@marionbarker
Copy link
Contributor

The walking override started at 1:47 with a duration of 3 hours and was cancelled 19 minutes later.

  • upper plot: While override is active. The bad news is the start point for the plot for both lock screen and dynamic island expanded plot is "now" instead of when override started.
  • lower plot: After disabling the override. The good news is that plotting a cancelled override was not repeated - perhaps that was related to the new build, or perhaps because it was cancelled instead of allowed to run the full duration.

override-status

@bastienmoulia
Copy link

Thanks for the blue area!

Same here for the bug with an override label shown even none were triggered
IMG_B15E4FD11EDD-1

@marionbarker
Copy link
Contributor

I did a bit more testing.

  • If an override is active, it is shown as starting "now"
  • If an override expires after the planned duration, it continues to be show starting "now"
  • If an override is cancelled early, no extraneous override is displayed

@bastienmoulia
Copy link

In the last update, I didn't see the target area for the next hour by default:
IMG_598D1AB784AD-1

If I activate the premeal, then remove it, it's ok.

@bastiaanv
Copy link
Author

@marionbarker I updated the LA with the following:

  • Fix for the Save button
  • Removed the auto-scaling and ported the Loop yAxis generator

Do you have time for a update of the customisation?

@marionbarker
Copy link
Contributor

The most recent updates to Live Activity have been incorporated in the customization script. Run the script again and you will be offered an update to Live Activity if you already have it installed.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/loopandlearn/lnl-scripts/main/CustomizationSelect.sh)"

Documentation overview for the script: https://www.loopandlearn.org/custom-code/#overview

@cachrisman
Copy link

cachrisman commented Sep 17, 2024

Just wanted to share something I just noticed - that with the live activity running, if my phone is in StandBy (mine is on a MagSafe desk charger), it shows my BG as a small bubble in the upper right of the clock and I can tap that and see the live activity full screen. Pretty neat!!

Keep up the good work everyone! Thank you for all you do!

IMG_0108
IMG_0109

@bastiaanv bastiaanv changed the title [DRAFT] feature: Live Activity feature: Live Activity Sep 19, 2024
@marionbarker
Copy link
Contributor

Sorry to be slow testing this.
I configured it on an SE.
I modified the Live Activity setting to disable the Always Enabled, and disabled the Show when Low is predicted, enabled the Show when High only.
However, the LA on Lock screen still showed up (there was a low at the time.)

Also, IMO, the Save button should be inactive unless there is a change to save. Then when it is tapped to save a change, the Save button should be inactive again.

@marionbarker
Copy link
Contributor

I did more testing - this is with an SE so I can only look at the lock screen - there is no dynamic island.

When Always enabled is off and glucose is between low and high settings, the lock screen shows the note on the left of the graphic below. (Tapping to update the widget does nothing unless you modify the setting to enable the Always enabled slider.)

Also, the two sliders for Show when low is predicted and Show when high is predicted have no effect. The live activity on the lock screen shows when glucose is below low or above high values regardless of whether those sliders are selected or not.

Live_Activity_pr2191

@bastiaanv
Copy link
Author

Reverted always on feature, since Apple doesn't allow a live activity to be created in the background. Only in the foreground or via push notifications.

Also added the change to have the save button disabled while there are no changes

@marionbarker
Copy link
Contributor

Summary:

  • I have the latest version of this PR on my Looping phone. (commit cc8ee11).
  • I have been using it since last summer.
  • I strongly recommend this be added to Loop as a feature; but there are some issues that could be addressed now or later.
  • This feature is enabled by entering Loop, Alert Management and using the new row labeled Live Activity.

Tests:

I have not tested this in a while. It seems to have the same issue we see in other features where you make a change, and the change is actually implemented, but it doesn't show up on the view. By going to another screen (or quit/restart the app) you can force the refresh for that screen with current values.

This happens for some Therapy Settings and Algorithm Experiment selections as well. It appears to be new with iOS 18.

This is an Issue reported for one display glitch and a PR proposed for another one:

I think we need a uniform fix for this for iOS 18.

Screens can show old settings

I did some testing with the screen where you can choose which 4 blocks you want on the bottom row on the lockscreen. The changes showed up on the Live Activity, but if I returned to the Bottom Row design in Loop, they showed the old selection. A quit/restart updated the view so my current selections were shown.

Save Button always active

The save button is still always active whether a change was made or not.

Features worked

Except for the display glitches mention above, all features and changes worked as expected.

Graphics of Controls

Some of the controls are shown on the screenshots below.

pr-2191-controls

Graphics on Lockscreen

The screenshots below show the lock screen

  • left side is when Mode: Small is selected (only shows the blocks selected for the Bottom Row)
  • right side when Mode: Large is selected with prediction lines enabled.

pr-2191-lockscreen

Copy link
Contributor

@marionbarker marionbarker left a comment

Choose a reason for hiding this comment

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

I approve this PR, but acknowledge it is subject to some UI glitches on some of the control views.

In practice, most people will configure the Live Activity layout one time and leave it alone. I have not modified the layout for mine since I last tested this PR.

However, if the UI glitches can be fixed easily, they should be.

@mns6754
Copy link

mns6754 commented Mar 21, 2025

Hi,
I didn’t build my own loop app, installed it through my health care provider (BC Diabetes). I’m not really a tech savvy; however, have a good handle on the loop app features (I think). I’m using iPhone 12 mini. I couldn’t find the Live Activity option in Alert Management. Is there any way to get this feature on my loop app/ phone even if I haven’t built my own loop app? After upgrading to IOS 18, the loop widget has become useless.

@bastiaanv
Copy link
Author

Hi @mns6754 ,

I am afraid not. Your health care provider needs to changes their Loop build to include LA.

Docs: https://www.loopandlearn.org/loop-features-in-development/#live-activity

@mns6754
Copy link

mns6754 commented Mar 22, 2025

Hi @mns6754 ,

I am afraid not. Your health care provider needs to changes their Loop build to include LA.

Docs: https://www.loopandlearn.org/loop-features-in-development/#live-activity

Thank you, Bastiaan, for the clarification

@marionbarker
Copy link
Contributor

marionbarker commented Mar 23, 2025

Status

Live Activity controls work as expected.
LGTM.

Test

Test again with the latest updates. Focus on the whether the configuration displays the just-modified selections after a change. (Before they were enacted, but the screen did not update right away.)

Configuration

IPhone SE 3rd gen, running iOS 18.3.2

  • LoopWorkspace dev, commit 3d48a5c
  • update Loop branch from this PR plus commit from PR 2298 (fix error accidentally introduced with PR 2295)

Test Save Button and Configuration Display

The Save button acts appropriately again (see this comment for details). This behavior is related to iOS 18 - older tests for this PR were with iOS 17.

Initially, the Live Activity screen Save button was inactive

  • Modify the Live Activity Mode from Large to Small, Save button becomes active
  • Tap save and save button becomes inactive
  • Tap back and return, Mode of Small is correctly displayed
  • Modify the Live Activity Mode from Small to Large, Save button becomes active
  • Tap back (without saving) and then return
    • Success: Mode still shows as Small and the Save button is inactive

Comprehensive Tests for Save Button and Configuration Display

Tests below include looking at the Live Activity on the Lock Screen. For "success", the LA must match the displayed configuration.

Repeat test for all rows on the Live Activity screen:

  • success: Enabled
  • success: Mode
  • success: Add predictive line (Large mode only)
  • success: Use BG coloring
  • success: Upper limit
  • success: Lower limit

Test Bottom Row configuration screen

Tests below include looking at the Live Activity on the Lock Screen. For "success", the LA must match the displayed configuration.

  • success: delete one item, save button active - back and return, no change
  • success: delete one item, save button active- save, back and return, change is displayed on screen
  • success: add one item, save button active - back and return, no change
  • success: add one item, save button active- save, back and return, change is displayed on screen
  • success: rearrange order, save button active - back and return, no change
  • success: rearrange order, save button active- save, back and return, change is displayed on screen

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.

8 participants