Closed arthurhammer closed 9 years ago
Nice work! I can take a look into the not working NSUserDefaultsDidChangeNotification. I all ready did that in an other project.
Am 29.10.2015 um 14:17 schrieb Arthur Hammer notifications@github.com:
14 https://github.com/thomasfinch/GammaThingy/issues/14 introduced a basic widget. I've been looking into a full widget. Since this required quite a bit of more work, I made this a new PR.
https://cloud.githubusercontent.com/assets/4521216/10815766/6f029fba-7e2e-11e5-9281-4186fc4e66bb.jpg UI and functions are simple but it's a good base to work from. I've been running this for a few days and it's quite stable.
Main Changes
App Groups
Extension and host app live in separate processes. They can only talk by using App Groups http://www.atomicbird.com/blog/sharing-with-app-extensions. Changing to app groups requires a bit of work:
Enabling App Group Capability for both host and extension. Adding a group identifier, usually group.
. Problem: As with the main bundle ID, it seems we can’t share a group ID. Everyone has their own. The best I came up with: Adding a project setting APP_GROUP_IDENTIFIER for everybody to set their group ID. In code, getting the identifier from the Info.plist. NSUserDefaults
To share defaults, now use [[NSUserDefaults alloc] initWithSuiteName:
] instead of standardUserDefaults. I added a category so we can just call [NSUserDefaults groupDefaults]. Call [defaults synchronize] when making changes. It seems NSUserDefaultsDidChangeNotification won't get delivered between widget and app http://stackoverflow.com/questions/28284989/nsuserdefaultsdidchangenotification-and-today-extensions. GammaController App and widget have their own GammaController class which write to their own gammatable.dat file. This leads to the problem where the widget initializes its file with already modified gamma data instead of the default screen values (or vice versa). It will then use this wrong data as the base level for adjustments.
I changed it to write the gammatable.dat into the shared app group space. Works for now but is not protected against concurrent writes. Although it's unlikely widget and app will write at the same time, this should be resolved. Maybe there is a better solution altogether that does not clutter GammaController with app group related stuff.
Problem
The group ID stuff increases the barrier to entry for users who just want to install the thing. You now have to: (see linked screenshots)
Add custom bundle ID to the main app (as before) https://cloud.githubusercontent.com/assets/4521216/10819152/d94683ce-7e46-11e5-9472-17a2ac69dc0a.png Add custom bundle ID to the extension https://cloud.githubusercontent.com/assets/4521216/10819167/e688ef40-7e46-11e5-896f-7147794e5680.png Create a group ID, add it to both main app https://cloud.githubusercontent.com/assets/4521216/10819192/ff74ff76-7e46-11e5-8ee6-a5bb1f6d39b1.png and extension https://cloud.githubusercontent.com/assets/4521216/10819204/0b2be370-7e47-11e5-8093-2947e89d6bce.png Insert the group ID into the project setting https://cloud.githubusercontent.com/assets/4521216/10819210/1cf99e76-7e47-11e5-87ca-9647843ee745.png I'm open for contributions and happy to change stuff as needed.
See also #14 https://github.com/thomasfinch/GammaThingy/issues/14, #33 https://github.com/thomasfinch/GammaThingy/pull/33.
You can view, comment on, or merge this pull request online at:
https://github.com/thomasfinch/GammaThingy/pull/44 https://github.com/thomasfinch/GammaThingy/pull/44 Commit Summary
Add Widget Target Add App Groups Switch NSUserDefaults to app group defaults Synchronize shared defaults Add widget controller logic Add widget UI Move registerDefaults to shared defaults plist Cleanup Share gammatable.dat between widget and host File Changes
M GammaTest.xcodeproj/project.pbxproj https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-0 (230) M GammaTest/AppDelegate.m https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-1 (25) A GammaTest/Defaults.plist https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-2 (30) A GammaTest/GammaTest.entitlements https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-3 (10) M GammaTest/Info.plist https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-4 (10) M GammaTest/MainViewController.m https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-5 (76) A GammaTest/extentions/NSUserDefaults+Group.h https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-6 (19) A GammaTest/extentions/NSUserDefaults+Group.m https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-7 (18) M GammaTest/mvc/controller/GammaController.m https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-8 (29) A GammaWidget/Base.lproj/MainInterface.storyboard https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-9 (157) A GammaWidget/GammaWidget.entitlements https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-10 (10) A GammaWidget/Info.plist https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-11 (35) A GammaWidget/TodayViewController.h https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-12 (13) A GammaWidget/TodayViewController.m https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-13 (117) Patch Links:
https://github.com/thomasfinch/GammaThingy/pull/44.patch https://github.com/thomasfinch/GammaThingy/pull/44.patch https://github.com/thomasfinch/GammaThingy/pull/44.diff https://github.com/thomasfinch/GammaThingy/pull/44.diff — Reply to this email directly or view it on GitHub https://github.com/thomasfinch/GammaThingy/pull/44.
Absolutely, that would be great.
On 29.10.2015, at 14:43, Ango notifications@github.com wrote:
Nice work! I can take a look into the not working NSUserDefaultsDidChangeNotification. I all ready did that in an other project.
Am 29.10.2015 um 14:17 schrieb Arthur Hammer notifications@github.com:
14 https://github.com/thomasfinch/GammaThingy/issues/14 introduced a basic widget. I've been looking into a full widget. Since this required quite a bit of more work, I made this a new PR.
https://cloud.githubusercontent.com/assets/4521216/10815766/6f029fba-7e2e-11e5-9281-4186fc4e66bb.jpg UI and functions are simple but it's a good base to work from. I've been running this for a few days and it's quite stable.
Main Changes
App Groups
Extension and host app live in separate processes. They can only talk by using App Groups http://www.atomicbird.com/blog/sharing-with-app-extensions. Changing to app groups requires a bit of work:
Enabling App Group Capability for both host and extension. Adding a group identifier, usually group.
. Problem: As with the main bundle ID, it seems we can’t share a group ID. Everyone has their own. The best I came up with: Adding a project setting APP_GROUP_IDENTIFIER for everybody to set their group ID. In code, getting the identifier from the Info.plist. NSUserDefaults
To share defaults, now use [[NSUserDefaults alloc] initWithSuiteName:
] instead of standardUserDefaults. I added a category so we can just call [NSUserDefaults groupDefaults]. Call [defaults synchronize] when making changes. It seems NSUserDefaultsDidChangeNotification won't get delivered between widget and app http://stackoverflow.com/questions/28284989/nsuserdefaultsdidchangenotification-and-today-extensions. GammaController App and widget have their own GammaController class which write to their own gammatable.dat file. This leads to the problem where the widget initializes its file with already modified gamma data instead of the default screen values (or vice versa). It will then use this wrong data as the base level for adjustments.
I changed it to write the gammatable.dat into the shared app group space. Works for now but is not protected against concurrent writes. Although it's unlikely widget and app will write at the same time, this should be resolved. Maybe there is a better solution altogether that does not clutter GammaController with app group related stuff.
Problem
The group ID stuff increases the barrier to entry for users who just want to install the thing. You now have to: (see linked screenshots)
Add custom bundle ID to the main app (as before) https://cloud.githubusercontent.com/assets/4521216/10819152/d94683ce-7e46-11e5-9472-17a2ac69dc0a.png Add custom bundle ID to the extension https://cloud.githubusercontent.com/assets/4521216/10819167/e688ef40-7e46-11e5-896f-7147794e5680.png Create a group ID, add it to both main app https://cloud.githubusercontent.com/assets/4521216/10819192/ff74ff76-7e46-11e5-8ee6-a5bb1f6d39b1.png and extension https://cloud.githubusercontent.com/assets/4521216/10819204/0b2be370-7e47-11e5-8093-2947e89d6bce.png Insert the group ID into the project setting https://cloud.githubusercontent.com/assets/4521216/10819210/1cf99e76-7e47-11e5-87ca-9647843ee745.png I'm open for contributions and happy to change stuff as needed.
See also #14 https://github.com/thomasfinch/GammaThingy/issues/14, #33 https://github.com/thomasfinch/GammaThingy/pull/33.
You can view, comment on, or merge this pull request online at:
https://github.com/thomasfinch/GammaThingy/pull/44 https://github.com/thomasfinch/GammaThingy/pull/44 Commit Summary
Add Widget Target Add App Groups Switch NSUserDefaults to app group defaults Synchronize shared defaults Add widget controller logic Add widget UI Move registerDefaults to shared defaults plist Cleanup Share gammatable.dat between widget and host File Changes
M GammaTest.xcodeproj/project.pbxproj https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-0 (230) M GammaTest/AppDelegate.m https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-1 (25) A GammaTest/Defaults.plist https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-2 (30) A GammaTest/GammaTest.entitlements https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-3 (10) M GammaTest/Info.plist https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-4 (10) M GammaTest/MainViewController.m https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-5 (76) A GammaTest/extentions/NSUserDefaults+Group.h https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-6 (19) A GammaTest/extentions/NSUserDefaults+Group.m https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-7 (18) M GammaTest/mvc/controller/GammaController.m https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-8 (29) A GammaWidget/Base.lproj/MainInterface.storyboard https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-9 (157) A GammaWidget/GammaWidget.entitlements https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-10 (10) A GammaWidget/Info.plist https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-11 (35) A GammaWidget/TodayViewController.h https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-12 (13) A GammaWidget/TodayViewController.m https://github.com/thomasfinch/GammaThingy/pull/44/files#diff-13 (117) Patch Links:
https://github.com/thomasfinch/GammaThingy/pull/44.patch https://github.com/thomasfinch/GammaThingy/pull/44.patch https://github.com/thomasfinch/GammaThingy/pull/44.diff https://github.com/thomasfinch/GammaThingy/pull/44.diff — Reply to this email directly or view it on GitHub https://github.com/thomasfinch/GammaThingy/pull/44.
— Reply to this email directly or view it on GitHub.
This is awesome. Well worth the extra steps to install, for me.
nice work !
33 introduced a basic widget. I've been looking into a full widget. Since this required quite a bit of more work, I made this a new PR.
UI and functions are simple but it's a good base to work from. I've been running this for a few days and it's quite stable.
Main Changes
App Groups
Extension and host app live in separate processes. They can only talk by using App Groups. Changing to app groups requires a bit of work:
group.<main bundle ID>
.Problem: As with the main bundle ID, it seems we can’t share a group ID. Everyone has their own. The best I came up with:
APP_GROUP_IDENTIFIER
for everybody to set their group ID.NSUserDefaults
[[NSUserDefaults alloc] initWithSuiteName:<group ID>]
instead ofstandardUserDefaults
. I added a category so we can just call[NSUserDefaults groupDefaults]
.[defaults synchronize]
when making changes.NSUserDefaultsDidChangeNotification
won't get delivered between widget and app.GammaController
App and widget have their own
GammaController
class which write to their owngammatable.dat
file. This leads to the problem where the widget initializes its file with already modified gamma data instead of the default screen values (or vice versa). It will then use this wrong data as the base level for adjustments.I changed it to write the
gammatable.dat
into the shared app group space. Works for now but is not protected against concurrent writes. Although it's unlikely widget and app will write at the same time, this should be resolved. Maybe there is a better solution altogether that does not clutter GammaController with app group related stuff.Problem
The group ID stuff increases the barrier to entry for users who just want to install the thing. You now have to: (see linked screenshots)
I'm open for contributions and happy to change stuff as needed.
See also #14, #33.