-
Notifications
You must be signed in to change notification settings - Fork 354
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
adding the "contact trick" #505
adding the "contact trick" #505
Conversation
Hello @yurique! OpenGlück maintainer here, nice to see you have been able to port this to xdripswift! 🥳 |
@callms hey hey! Btw, a bit off-topic: I tried running the OpenGlück-server but never managed to get it to work (it doesn't seem to be creating the initial user and keeps sending me back to the create-user page) (I was trying to launch it inside k8s, so it could be a misconfiguration on my side - but I couldn't figure it out) |
Thanks for pointing it out, I think it was somehow broken when I added multi-user. I think it should be fixed in open-gluck/opengluck-server#28 |
What a cool addition! Now I just need to get it to work :-) Any special requirements for the contact that is used? I am not seeing any picture being added to this contact, so still just seeing the x. And should it work both as NS follower and Dexcom master (receiver)? Thanks! |
@bjornoleh I don't know enough about the internals of xdrip, but the contact trick is just subscribing to receive updates whenever there is a new BG reading available and then renders it into the contact picture - I'm assuming it doesn't matter if it's in follower or master mode (though I could be wrong about this). I have only tested it on my phone, and in the simulator - and for me it "just works". Is there a chance you could get the logs from the app? (if you're running it from xcode - the logs should show up there, in the debugger - otherwise you can send the logs from within the app - "Send Issue Report"). In case of errors it should log messages starting with |
Thanks for your reply. I am trying to get this to work in a S3, which only gets to watchOS 8. Any limitations here? Regarding the contact added, can any contact (with a fake email address?) be used, or is a specific one like in your screenshot needed? |
(Original OG implementor here.) It should work with any watchOS version compatible with xdripswift, just like when using the calendar trick. watchOS doesn't have limitations on Apple widgets as far as refresh goes. |
Thanks! Can any contact be used, or only a specific email (there is a specific one menton the OG readme)? I also tested adding a picture to the contact to see if that was displayed, and it was (but rather small on the 38 mm S3). The picture was not updated though. |
Any contact should work - it stores the ID of the contact you select in the settings, and then finds the contact by that ID and updates it. |
Ok, thanks. I did find |
@bjornoleh that's a very good start! There is an error, but its message is not logged. I just pushed an update that should log a bit more details about why it's failing. |
@bjornoleh by any chance, can you double-check if permissions allow xdripswift to update contacts? |
Thank @callms for looking into this! I rebuilt with the additional logging now. Then I verified that the contacts permission is given: Disabled, noted the warning in Xdrip when toggling on the contacts trick, then gave permission and started testing again. I get
|
It looks like the contact is read-only. I don't really know, why. Is it a regular contact on your phone? Is there anything "special" about it? |
I don't think there is anything special about it. It is given a name (xd) and has the same email as in your readme ([email protected]) I have tried various other contacts too. The picture was displayed on the S3 watch when I set a contact picture manually. The phone is a kids phone with some Screen Time restrictions. Not sure if any of that could interfere? The phone also shared its iCloud with another phone used as a follower phone by other caregivers, so the account had two associated phone numbers. I thought this could matter, and signed the outer phone out of iCloud. I rebooted phone and watch afterwards for good measure. But no difference still. |
@bjornoleh by any chance, does it work when you update the contact from your phone? Does it work when you create a new contact? |
Yes, I can change the contact picture manually, it updates on the watch |
It seems like some kind of restriction on the phone - Screen Time, iCloud, something else? Unfortunately, I know next to nothing about all of this :( |
Once 5.2.0 is released, we'll look at getting this PR merged in @yurique , @callms . Nice work! We'd need to try and limit the settings options if possible. Can the font size/type and also the dark mode option be removed? I mean can we use a fixed/system font and have SwiftUI scale it to the size needed to fit the circularAccessory widget? |
Another thought... although technically the name "Contact Trick" would work for devs because it accurately describes what it is, I don't think it would work well for public release. In fact translating this into other languages would probably create confusion that would need further explanation. The fact that it's a trick/workaround/exploit shouldn't be worded into the description itself. Do you guys have any other ideas that could be used? For example, "Calendar events" works well because it is exactly what it is, an event in the calendar. But I'm struggling to think of a better name for this that doesn't use the work "trick". If this is also only for Watch complications, then maybe this needs to be clearer too. Maybe something like "Watch contact complication" would work but it's maybe a bit long. |
What about Contact Sync. At least in the docs there will be needed some kind of explanation. But agree, that trick is probably not the best term... |
Definitely! The renderer is already trying to adjust the font size to fit it into the area. Dark mode - this was an attempt to make it work on both dark and brighter watch backgrounds. But it looks like the watch is able to be somewhat smart about it. I tried playing with it just now: when I'm changing the color "scheme" - the watch is replacing the white text color on the contact pictures with the color I select. I've never used a non-black background, though. Font name - I was trying to find a font that looks the most readable in a small complication, but system default looks decent as well. |
I personally like it, “Contact Sync” and “Calendar Sync” would make it even to understand for non-developers if we were to talk about the two in the same sentence. |
@paulplant sounds good to me! But definitely - please feel free to adjust it as much as you find necessary :) |
I have only used it on the watch. One can put a contact widget on the phone as well (or even on the desktop in macOS) but I'm not sure if it's useful. |
Sorry, didn't get to this yesterday :/. Now aiming for today :) |
# Conflicts: # xdrip.xcodeproj/project.pbxproj # xdrip/Constants/ConstantsLog.swift # xdrip/View Controllers/Root View Controller/RootViewController.swift
Conflicts resolved, now going to remove some of the font settings. |
Great... let me know when ready and I'll probably cherry pick your commits into my staging branch and we can finish working on it there. |
@yurique @paulplant is it worth verifying fastlane build-ability now, or wait for the RC in your staging branch, Paul? Just curious when to best set aside a bit of time to test. |
@dnzxy I just pushed a commit removing some of the settings. It builds in xcode, but I haven't tested it yet. |
I‘ll spin up a build tonight and see how it goes. Pretty confident that it should build fine. Doesn’t look like this should break the fastlane build 😊🤞 |
I would hang off for a bit... when I saw the changes you did 2 weeks ago I know understand what causes things to break in the fastlane build and there shouldn't be anything like that yet. Last time we were up against the 90 day expiry so had to really push to get 5.1.0 out and then we were rushing hot-fixes out for a few days. This time we've got lots of time so it's better to wait until everything hits develop in the next week or so and then we can calmly test fastlane before release. There's no rush this time and we'll make sure it's all ready before release. |
I added a staging branch: https://github.com/JohanDegraeve/xdripswift/commits/staging-5.2/ |
looks like I missed to stage one of the changes when when committing (removing the reference to |
Please open a PR with them into this branch |
@paulplant here it is: #527 |
FWIW: Staging 5.2 (with all things merged) is building fine 🚀 see successful run at https://github.com/dnzxy/xdripswift/actions/runs/8651372734/job/23721981359 |
They'll be a lot more commits going to that branch over the next week or two so I'll tag you again when it's worth re-checking. Thanks!! |
Anytime! 🤝 I just wanted to make sure that this feature is building without issue (as expected; now verified). |
Sounds perfectly fine! (I don't really have any preferences regarding the name :) ) |
@yurique , @callms , @m-a-v , @dnzxy , @bjornoleh , @LiroyvH I think this should now be pretty much ready for pushing to develop. If you want to build and test: (note that the 5.2.0 staging branch also has Watch app/complication background refresh implemented amongst other stuff) I've rewrote a lot of the ContactImageView struct and adapted the style to match fully the xDrip4iOS UI. I removed also the rangeIndicator as this is already explicitly implied by the bg value text color in xDrip4iOS UI style. I think that the "Show trend" could also be removed and just always shown if available, but I guess this might be going too far in paring things down :) Also changed quite a lot of ContactImageManager class. To try and simplify things for the user, they now don't need create and select an e-mail address/contact. The app will now automatically create a contact based on ConstantsHomeView.applicationName (to allow this to work with Shuggah and other forks cleanly) and keep that contact updated. It'll also add the data source info to the contact organisation and add a note when it's first created to avoid confusion when the user sees that a new contact has appeared (in case they forget). When the user disables the contact image function, the app will now automatically delete the contact to clean up after itself*
Initial localisations added for English and Spanish. If you want me to quickly add other languages, just copy/paste this with the new strings in the comments:
|
Note: In the above xDrip4iOS Watch Complication you can see WCSession.remainingComplicationUserInfoTransfers shown in cyan color. The idea is that this will reach 0 at around 23hrs (bed time)... This will be removed for merging, it's just there for debugging now. |
Great work you guys! One small suggestion: can the white border of the circle be used as the range indicator color and the BG be in plain white? Similar to the battery complication in the left of the screenshotted watch face? Most if not all watch complications use white as text color and give color to all other shapes or elements, hence the idea. For the translation, I can supply German. |
unfortunately, the white circle is part of the contact complication UI - it's always there around the actual contact picture |
When I first started looking at it, I thought the same, but it's as @yurique says, we can't do anything to avoid it. |
Okay, strike that thought then. Still fire. Awesome work! 👏 |
Fixes #481.
Most of this PR is adding the new settings section to the iOS app.
The contact image rendering itself is heavily inspired by the implementation in OpenGlück, but I modified it quite a bit to support more customizations (and removed things related to "episodes", etc).
This is my first time coding for iOS, as well as first time coding in swift or in xcode – please feel free to nitpick all the things :)
Does it work? - Yes!
I kept the original G7 complication on my watch together with the "contact trick" for a while - feels like half of the time I was looking, the G7 complication was either not showing anything (
--
) or showing the outdated reading (the previous one), while the contact picture updates almost immediately and has been up-to-date all the time.