diff --git a/GammaTest.xcodeproj/project.pbxproj b/GammaTest.xcodeproj/project.pbxproj index df0ea43..4a92bef 100644 --- a/GammaTest.xcodeproj/project.pbxproj +++ b/GammaTest.xcodeproj/project.pbxproj @@ -7,14 +7,29 @@ objects = { /* Begin PBXBuildFile section */ - AFD8E7281BCA6A3D00BCC80A /* brightness.c in Sources */ = {isa = PBXBuildFile; fileRef = AFD8E7261BCA6A3D00BCC80A /* brightness.c */; settings = {ASSET_TAGS = (); }; }; - AFD8E72C1BCA6D4000BCC80A /* solar.c in Sources */ = {isa = PBXBuildFile; fileRef = AFD8E72A1BCA6D4000BCC80A /* solar.c */; settings = {ASSET_TAGS = (); }; }; - AFD8E7331BCA711300BCC80A /* GammaController.m in Sources */ = {isa = PBXBuildFile; fileRef = AFD8E7321BCA711300BCC80A /* GammaController.m */; settings = {ASSET_TAGS = (); }; }; + 001E848A1BE20544002871BD /* Defaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = 001E84891BE20544002871BD /* Defaults.plist */; }; + 001E848B1BE20544002871BD /* Defaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = 001E84891BE20544002871BD /* Defaults.plist */; }; + 0024BBA91BDF6B18007A5FA1 /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0024BBA81BDF6B18007A5FA1 /* NotificationCenter.framework */; }; + 0024BBAD1BDF6B19007A5FA1 /* TodayViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0024BBAC1BDF6B19007A5FA1 /* TodayViewController.m */; }; + 0024BBB01BDF6B19007A5FA1 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0024BBAE1BDF6B19007A5FA1 /* MainInterface.storyboard */; }; + 0024BBB41BDF6B19007A5FA1 /* GammaWidget.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 0024BBA61BDF6B18007A5FA1 /* GammaWidget.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 0024BBC81BDF6E2D007A5FA1 /* SpringBoardServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9DCA8871BBDF65900C449B0 /* SpringBoardServices.framework */; }; + 0024BBC91BDF6E7C007A5FA1 /* BackBoardServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B92DD5F81BB33DD700DC6E8F /* BackBoardServices.framework */; }; + 0024BBCA1BDF6E7E007A5FA1 /* IOMobileFramebuffer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B96BB6551B38DDB600F1C3AE /* IOMobileFramebuffer.framework */; }; + 0024BBCB1BDF6E80007A5FA1 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B96BB6531B38DDA500F1C3AE /* IOKit.framework */; }; + 0024BBCC1BDF6E85007A5FA1 /* GammaController.m in Sources */ = {isa = PBXBuildFile; fileRef = AFD8E7321BCA711300BCC80A /* GammaController.m */; }; + 0024BBCD1BDF6E95007A5FA1 /* solar.c in Sources */ = {isa = PBXBuildFile; fileRef = AFD8E72A1BCA6D4000BCC80A /* solar.c */; }; + 0024BBCE1BDF6E9A007A5FA1 /* brightness.c in Sources */ = {isa = PBXBuildFile; fileRef = AFD8E7261BCA6A3D00BCC80A /* brightness.c */; }; + 003B304A1BE0CB7000BFF1E6 /* NSUserDefaults+Group.m in Sources */ = {isa = PBXBuildFile; fileRef = 003B30491BE0CB7000BFF1E6 /* NSUserDefaults+Group.m */; }; + 003B304B1BE0CBCA00BFF1E6 /* NSUserDefaults+Group.m in Sources */ = {isa = PBXBuildFile; fileRef = 003B30491BE0CB7000BFF1E6 /* NSUserDefaults+Group.m */; }; + AFD8E7281BCA6A3D00BCC80A /* brightness.c in Sources */ = {isa = PBXBuildFile; fileRef = AFD8E7261BCA6A3D00BCC80A /* brightness.c */; }; + AFD8E72C1BCA6D4000BCC80A /* solar.c in Sources */ = {isa = PBXBuildFile; fileRef = AFD8E72A1BCA6D4000BCC80A /* solar.c */; }; + AFD8E7331BCA711300BCC80A /* GammaController.m in Sources */ = {isa = PBXBuildFile; fileRef = AFD8E7321BCA711300BCC80A /* GammaController.m */; }; B92DD5F91BB33DD700DC6E8F /* BackBoardServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B92DD5F81BB33DD700DC6E8F /* BackBoardServices.framework */; }; B96BB6511B38DAF500F1C3AE /* Launch Screen.xib in Resources */ = {isa = PBXBuildFile; fileRef = B96BB6501B38DAF500F1C3AE /* Launch Screen.xib */; }; B96BB6541B38DDA500F1C3AE /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B96BB6531B38DDA500F1C3AE /* IOKit.framework */; }; B96BB6561B38DDB600F1C3AE /* IOMobileFramebuffer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B96BB6551B38DDB600F1C3AE /* IOMobileFramebuffer.framework */; }; - B9B2BD3A1BA7B86000514B7A /* Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B9B2BD391BA7B86000514B7A /* Storyboard.storyboard */; settings = {ASSET_TAGS = (); }; }; + B9B2BD3A1BA7B86000514B7A /* Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B9B2BD391BA7B86000514B7A /* Storyboard.storyboard */; }; B9DCA8881BBDF65900C449B0 /* SpringBoardServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9DCA8871BBDF65900C449B0 /* SpringBoardServices.framework */; }; B9E5364B1B38D90D0097BF90 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B9E5364A1B38D90D0097BF90 /* main.m */; }; B9E5364E1B38D90D0097BF90 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B9E5364D1B38D90D0097BF90 /* AppDelegate.m */; }; @@ -22,6 +37,16 @@ B9E536561B38D90D0097BF90 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B9E536551B38D90D0097BF90 /* Assets.xcassets */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 0024BBB21BDF6B19007A5FA1 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B9E5363E1B38D90D0097BF90 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 0024BBA51BDF6B18007A5FA1; + remoteInfo = GammaWidget; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXCopyFilesBuildPhase section */ B9B6D3161BA636DA00A8E999 /* Embed App Extensions */ = { isa = PBXCopyFilesBuildPhase; @@ -29,6 +54,7 @@ dstPath = ""; dstSubfolderSpec = 13; files = ( + 0024BBB41BDF6B19007A5FA1 /* GammaWidget.appex in Embed App Extensions */, ); name = "Embed App Extensions"; runOnlyForDeploymentPostprocessing = 0; @@ -36,6 +62,17 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 001E84891BE20544002871BD /* Defaults.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Defaults.plist; sourceTree = ""; }; + 0024BBA61BDF6B18007A5FA1 /* GammaWidget.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = GammaWidget.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + 0024BBA81BDF6B18007A5FA1 /* NotificationCenter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NotificationCenter.framework; path = System/Library/Frameworks/NotificationCenter.framework; sourceTree = SDKROOT; }; + 0024BBAB1BDF6B19007A5FA1 /* TodayViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TodayViewController.h; sourceTree = ""; }; + 0024BBAC1BDF6B19007A5FA1 /* TodayViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TodayViewController.m; sourceTree = ""; }; + 0024BBAF1BDF6B19007A5FA1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; + 0024BBB11BDF6B19007A5FA1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 003B30461BE0C96700BFF1E6 /* GammaTest.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = GammaTest.entitlements; sourceTree = ""; }; + 003B30471BE0C9B700BFF1E6 /* GammaWidget.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = GammaWidget.entitlements; sourceTree = ""; }; + 003B30481BE0CB7000BFF1E6 /* NSUserDefaults+Group.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSUserDefaults+Group.h"; path = "extentions/NSUserDefaults+Group.h"; sourceTree = ""; }; + 003B30491BE0CB7000BFF1E6 /* NSUserDefaults+Group.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSUserDefaults+Group.m"; path = "extentions/NSUserDefaults+Group.m"; sourceTree = ""; }; AFD8E7261BCA6A3D00BCC80A /* brightness.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = brightness.c; path = libs/brightness/brightness.c; sourceTree = ""; }; AFD8E7271BCA6A3D00BCC80A /* brightness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = brightness.h; path = libs/brightness/brightness.h; sourceTree = ""; }; AFD8E72A1BCA6D4000BCC80A /* solar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = solar.c; path = libs/solar/solar.c; sourceTree = ""; }; @@ -87,6 +124,18 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 0024BBA31BDF6B18007A5FA1 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0024BBC81BDF6E2D007A5FA1 /* SpringBoardServices.framework in Frameworks */, + 0024BBC91BDF6E7C007A5FA1 /* BackBoardServices.framework in Frameworks */, + 0024BBCA1BDF6E7E007A5FA1 /* IOMobileFramebuffer.framework in Frameworks */, + 0024BBCB1BDF6E80007A5FA1 /* IOKit.framework in Frameworks */, + 0024BBA91BDF6B18007A5FA1 /* NotificationCenter.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B9E536431B38D90D0097BF90 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -101,12 +150,34 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - AF2C35091BD168C100BBCF8F /* extentions */ = { + 0024BBA71BDF6B18007A5FA1 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 0024BBA81BDF6B18007A5FA1 /* NotificationCenter.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 0024BBAA1BDF6B19007A5FA1 /* GammaWidget */ = { + isa = PBXGroup; + children = ( + 0024BBAB1BDF6B19007A5FA1 /* TodayViewController.h */, + 0024BBAC1BDF6B19007A5FA1 /* TodayViewController.m */, + 0024BBAE1BDF6B19007A5FA1 /* MainInterface.storyboard */, + 0024BBB11BDF6B19007A5FA1 /* Info.plist */, + 003B30471BE0C9B700BFF1E6 /* GammaWidget.entitlements */, + ); + path = GammaWidget; + sourceTree = ""; + }; + AF2C35091BD168C100BBCF8F /* extensions */ = { isa = PBXGroup; children = ( AFEEB5D11BD1692600F56616 /* NSDate_compare.h */, + 003B30481BE0CB7000BFF1E6 /* NSUserDefaults+Group.h */, + 003B30491BE0CB7000BFF1E6 /* NSUserDefaults+Group.m */, ); - name = extentions; + name = extensions; sourceTree = ""; }; AFD8E7241BCA69CC00BCC80A /* libs */ = { @@ -162,6 +233,8 @@ isa = PBXGroup; children = ( B9E536481B38D90D0097BF90 /* GammaTest */, + 0024BBAA1BDF6B19007A5FA1 /* GammaWidget */, + 0024BBA71BDF6B18007A5FA1 /* Frameworks */, B9E536471B38D90D0097BF90 /* Products */, ); sourceTree = ""; @@ -170,6 +243,7 @@ isa = PBXGroup; children = ( B9E536461B38D90D0097BF90 /* GammaTest.app */, + 0024BBA61BDF6B18007A5FA1 /* GammaWidget.appex */, ); name = Products; sourceTree = ""; @@ -177,7 +251,7 @@ B9E536481B38D90D0097BF90 /* GammaTest */ = { isa = PBXGroup; children = ( - AF2C35091BD168C100BBCF8F /* extentions */, + AF2C35091BD168C100BBCF8F /* extensions */, AFD8E72D1BCA6E5600BCC80A /* controller */, AFD8E7241BCA69CC00BCC80A /* libs */, B9E5364C1B38D90D0097BF90 /* AppDelegate.h */, @@ -188,6 +262,8 @@ B9B2BD391BA7B86000514B7A /* Storyboard.storyboard */, B9E536551B38D90D0097BF90 /* Assets.xcassets */, B9E5365A1B38D90D0097BF90 /* Info.plist */, + 001E84891BE20544002871BD /* Defaults.plist */, + 003B30461BE0C96700BFF1E6 /* GammaTest.entitlements */, B9E536601B38D92C0097BF90 /* IOKit Headers */, B9E536491B38D90D0097BF90 /* Supporting Files */, ); @@ -264,6 +340,23 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 0024BBA51BDF6B18007A5FA1 /* GammaWidget */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0024BBB51BDF6B19007A5FA1 /* Build configuration list for PBXNativeTarget "GammaWidget" */; + buildPhases = ( + 0024BBA21BDF6B18007A5FA1 /* Sources */, + 0024BBA31BDF6B18007A5FA1 /* Frameworks */, + 0024BBA41BDF6B18007A5FA1 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = GammaWidget; + productName = GammaWidget; + productReference = 0024BBA61BDF6B18007A5FA1 /* GammaWidget.appex */; + productType = "com.apple.product-type.app-extension"; + }; B9E536451B38D90D0097BF90 /* GammaTest */ = { isa = PBXNativeTarget; buildConfigurationList = B9E5365D1B38D90D0097BF90 /* Build configuration list for PBXNativeTarget "GammaTest" */; @@ -276,6 +369,7 @@ buildRules = ( ); dependencies = ( + 0024BBB31BDF6B19007A5FA1 /* PBXTargetDependency */, ); name = GammaTest; productName = GammaTest; @@ -288,13 +382,25 @@ B9E5363E1B38D90D0097BF90 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0710; ORGANIZATIONNAME = "Thomas Finch"; TargetAttributes = { + 0024BBA51BDF6B18007A5FA1 = { + CreatedOnToolsVersion = 7.1; + DevelopmentTeam = HN76YBFY6K; + SystemCapabilities = { + com.apple.ApplicationGroups.iOS = { + enabled = 1; + }; + }; + }; B9E536451B38D90D0097BF90 = { CreatedOnToolsVersion = 7.0; - DevelopmentTeam = WV4RMF773Y; + DevelopmentTeam = HN76YBFY6K; SystemCapabilities = { + com.apple.ApplicationGroups.iOS = { + enabled = 1; + }; com.apple.BackgroundModes = { enabled = 1; }; @@ -316,15 +422,26 @@ projectRoot = ""; targets = ( B9E536451B38D90D0097BF90 /* GammaTest */, + 0024BBA51BDF6B18007A5FA1 /* GammaWidget */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 0024BBA41BDF6B18007A5FA1 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 001E848B1BE20544002871BD /* Defaults.plist in Resources */, + 0024BBB01BDF6B19007A5FA1 /* MainInterface.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B9E536441B38D90D0097BF90 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 001E848A1BE20544002871BD /* Defaults.plist in Resources */, B9E536561B38D90D0097BF90 /* Assets.xcassets in Resources */, B96BB6511B38DAF500F1C3AE /* Launch Screen.xib in Resources */, B9B2BD3A1BA7B86000514B7A /* Storyboard.storyboard in Resources */, @@ -334,6 +451,18 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 0024BBA21BDF6B18007A5FA1 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0024BBCD1BDF6E95007A5FA1 /* solar.c in Sources */, + 0024BBAD1BDF6B19007A5FA1 /* TodayViewController.m in Sources */, + 0024BBCE1BDF6E9A007A5FA1 /* brightness.c in Sources */, + 0024BBCC1BDF6E85007A5FA1 /* GammaController.m in Sources */, + 003B304B1BE0CBCA00BFF1E6 /* NSUserDefaults+Group.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B9E536421B38D90D0097BF90 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -344,16 +473,81 @@ AFD8E72C1BCA6D4000BCC80A /* solar.c in Sources */, AFD8E7331BCA711300BCC80A /* GammaController.m in Sources */, AFD8E7281BCA6A3D00BCC80A /* brightness.c in Sources */, + 003B304A1BE0CB7000BFF1E6 /* NSUserDefaults+Group.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 0024BBB31BDF6B19007A5FA1 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 0024BBA51BDF6B18007A5FA1 /* GammaWidget */; + targetProxy = 0024BBB21BDF6B19007A5FA1 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 0024BBAE1BDF6B19007A5FA1 /* MainInterface.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 0024BBAF1BDF6B19007A5FA1 /* Base */, + ); + name = MainInterface.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ + 0024BBB61BDF6B19007A5FA1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = GammaWidget/GammaWidget.entitlements; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/GammaWidget", + "$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks", + "$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/PrivateFrameworks", + ); + INFOPLIST_FILE = GammaWidget/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = me.ahammer.GammaTest.GammaWidget; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 0024BBB71BDF6B19007A5FA1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = GammaWidget/GammaWidget.entitlements; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/GammaWidget", + "$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks", + "$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/PrivateFrameworks", + ); + INFOPLIST_FILE = GammaWidget/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = me.ahammer.GammaTest.GammaWidget; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + SKIP_INSTALL = YES; + }; + name = Release; + }; B9E5365B1B38D90D0097BF90 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + APP_GROUP_IDENTIFIER = group.me.ahammer.GammaTest; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -397,6 +591,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + APP_GROUP_IDENTIFIER = group.me.ahammer.GammaTest; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -433,8 +628,8 @@ B9E5365E1B38D90D0097BF90 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = GammaTest/GammaTest.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; FRAMEWORK_SEARCH_PATHS = ( @@ -445,7 +640,7 @@ INFOPLIST_FILE = GammaTest/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 7.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = me.caspercl.GammaTest; + PRODUCT_BUNDLE_IDENTIFIER = me.ahammer.GammaTest; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; TARGETED_DEVICE_FAMILY = "1,2"; @@ -455,8 +650,8 @@ B9E5365F1B38D90D0097BF90 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = GammaTest/GammaTest.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; FRAMEWORK_SEARCH_PATHS = ( @@ -467,7 +662,7 @@ INFOPLIST_FILE = GammaTest/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 7.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = me.caspercl.GammaTest; + PRODUCT_BUNDLE_IDENTIFIER = me.ahammer.GammaTest; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; TARGETED_DEVICE_FAMILY = "1,2"; @@ -477,6 +672,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 0024BBB51BDF6B19007A5FA1 /* Build configuration list for PBXNativeTarget "GammaWidget" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0024BBB61BDF6B19007A5FA1 /* Debug */, + 0024BBB71BDF6B19007A5FA1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; B9E536411B38D90D0097BF90 /* Build configuration list for PBXProject "GammaTest" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/GammaTest/AppDelegate.m b/GammaTest/AppDelegate.m index 41d5f3e..c0ac118 100644 --- a/GammaTest/AppDelegate.m +++ b/GammaTest/AppDelegate.m @@ -9,7 +9,7 @@ #import "AppDelegate.h" #import "MainViewController.h" #import "GammaController.h" - +#import "NSUserDefaults+Group.h" typedef NS_ENUM(NSInteger, GammaAction) { GammaActionNone, @@ -59,20 +59,9 @@ - (void)updateShortCutItem { - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [application setMinimumBackgroundFetchInterval:900]; //Wake up every 15 minutes at minimum - [[NSUserDefaults standardUserDefaults] registerDefaults:@{ - @"enabled": @NO, - @"maxOrange": [NSNumber numberWithFloat:0.7], - @"colorChangingEnabled": @YES, - @"lastAutoChangeDate": [NSDate distantPast], - @"autoStartHour": @19, - @"autoStartMinute": @0, - @"autoEndHour": @7, - @"autoEndMinute": @0, - @"updateUI":@YES, - @"colorChangingLocationLatitude": @0, - @"colorChangingLocationLongitude": @0, - @"colorChangingLocationEnabled": @NO - }]; + NSString *defaultsPath = [[NSBundle mainBundle] pathForResource:@"Defaults" ofType:@"plist"]; + NSDictionary *appDefaults = [NSDictionary dictionaryWithContentsOfFile:defaultsPath]; + [[NSUserDefaults groupDefaults] registerDefaults:appDefaults]; if ([application respondsToSelector:@selector(shortcutItems)] && !application.shortcutItems.count) { @@ -84,6 +73,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( return YES; } +- (void)applicationDidBecomeActive:(UIApplication *)application { + [[NSUserDefaults groupDefaults] setBool:YES forKey:@"updateUI"]; +} + - (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{ NSLog(@"App woke with fetch request"); @@ -108,7 +101,7 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDiction } } else { //gammathingy://orangeness/switch - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"enabled"]) { + if ([[NSUserDefaults groupDefaults] boolForKey:@"enabled"]) { [GammaController disableOrangeness]; } else { [GammaController enableOrangeness]; diff --git a/GammaTest/Defaults.plist b/GammaTest/Defaults.plist new file mode 100644 index 0000000..502ed26 --- /dev/null +++ b/GammaTest/Defaults.plist @@ -0,0 +1,30 @@ + + + + + enabled + + maxOrange + 0.7 + colorChangingEnabled + + lastAutoChangeDate + 1-01-01T00:07:33Z + autoStartHour + 19 + autoStartMinute + 0 + autoEndHour + 7 + autoEndMinute + 0 + updateUI + + colorChangingLocationLatitude + 0 + colorChangingLocationLongitude + 0 + colorChangingLocationEnabled + + + diff --git a/GammaTest/GammaTest.entitlements b/GammaTest/GammaTest.entitlements new file mode 100644 index 0000000..46da1a6 --- /dev/null +++ b/GammaTest/GammaTest.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.me.ahammer.GammaTest + + + diff --git a/GammaTest/Info.plist b/GammaTest/Info.plist index 0b14329..a464c66 100644 --- a/GammaTest/Info.plist +++ b/GammaTest/Info.plist @@ -2,10 +2,12 @@ - NSLocationWhenInUseUsageDescription - Your location is required once in order to provide location based screen temperature + AppGroupIdentifier + $(APP_GROUP_IDENTIFIER) CFBundleDevelopmentRegion en + CFBundleDisplayName + Gamma Thingy CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -35,6 +37,8 @@ 1 LSRequiresIPhoneOS + NSLocationWhenInUseUsageDescription + Your location is required once in order to provide location based screen temperature UIBackgroundModes fetch @@ -49,8 +53,6 @@ armv7 - CFBundleDisplayName - Gamma Thingy UISupportedInterfaceOrientations UIInterfaceOrientationPortrait diff --git a/GammaTest/MainViewController.m b/GammaTest/MainViewController.m index 3cceb41..3a88ac9 100644 --- a/GammaTest/MainViewController.m +++ b/GammaTest/MainViewController.m @@ -8,6 +8,7 @@ #import "MainViewController.h" #import "GammaController.h" +#import "NSUserDefaults+Group.h" @interface MainViewController () @@ -80,7 +81,7 @@ - (void)viewDidLoad { } - (void)updateUI { - NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; + NSUserDefaults* defaults = [NSUserDefaults groupDefaults]; enabledSwitch.on = [defaults boolForKey:@"enabled"]; orangeSlider.value = [defaults floatForKey:@"maxOrange"]; @@ -95,38 +96,43 @@ - (void)updateUI { - (IBAction)enabledSwitchChanged:(UISwitch *)sender { NSLog(@"enabled: %lu",(unsigned long)sender.on); - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"updateUI"]; + NSUserDefaults* defaults = [NSUserDefaults groupDefaults]; + [defaults setBool:NO forKey:@"updateUI"]; if (sender.on) { - [GammaController setGammaWithTransitionFrom:0 to:[[NSUserDefaults standardUserDefaults] floatForKey:@"maxOrange"]]; + [GammaController enableOrangeness]; } else { - [GammaController setGammaWithTransitionFrom:[[NSUserDefaults standardUserDefaults] floatForKey:@"maxOrange"] to:0]; + [GammaController disableOrangeness]; } - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"colorChangingLocationEnabled"]) { - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"colorChangingLocationEnabled"]; + if ([defaults boolForKey:@"colorChangingLocationEnabled"]) { + [defaults setBool:NO forKey:@"colorChangingLocationEnabled"]; } - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"colorChangingLocationEnabled"]) { - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"colorChangingEnabled"]; + if ([defaults boolForKey:@"colorChangingLocationEnabled"]) { + [defaults setBool:NO forKey:@"colorChangingEnabled"]; } - - [[NSUserDefaults standardUserDefaults] setBool:sender.on forKey:@"enabled"]; - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"updateUI"]; + [defaults setBool:YES forKey:@"updateUI"]; + [defaults synchronize]; } - (IBAction)maxOrangeSliderChanged:(UISlider *)sender { NSLog(@"maxOrange: %f",sender.value); - [[NSUserDefaults standardUserDefaults] setFloat:sender.value forKey:@"maxOrange"]; + NSUserDefaults *defaults = [NSUserDefaults groupDefaults]; + [defaults setFloat:sender.value forKey:@"maxOrange"]; - if (enabledSwitch.on) + if (enabledSwitch.on) { [GammaController setGammaWithOrangeness:sender.value]; + } + + [defaults synchronize]; } - (IBAction)colorChangingEnabledSwitchChanged:(UISwitch *)sender { NSLog(@"colorChangingEnabled: %lu",(unsigned long)sender.on); - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"updateUI"]; - [[NSUserDefaults standardUserDefaults] setBool:sender.on forKey:@"colorChangingEnabled"]; - [[NSUserDefaults standardUserDefaults] setObject:[NSDate distantPast] forKey:@"lastAutoChangeDate"]; + NSUserDefaults *defaults = [NSUserDefaults groupDefaults]; + [defaults setBool:NO forKey:@"updateUI"]; + [defaults setBool:sender.on forKey:@"colorChangingEnabled"]; + [defaults setObject:[NSDate distantPast] forKey:@"lastAutoChangeDate"]; NSLog(@"color changing switch changed"); if(sender.on) { @@ -137,16 +143,20 @@ - (IBAction)colorChangingEnabledSwitchChanged:(UISwitch *)sender { // Make the time fields full opacity. for(UITableViewCell *cell in timeBasedInputCells) [[cell contentView] setAlpha: 1]; - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"colorChangingLocationEnabled"]; - [[NSUserDefaults standardUserDefaults] setBool:sender.on forKey:@"colorChangingEnabled"]; + [defaults setBool:NO forKey:@"colorChangingLocationEnabled"]; + [defaults setBool:sender.on forKey:@"colorChangingEnabled"]; } - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"updateUI"]; + + [defaults setBool:YES forKey:@"updateUI"]; [GammaController autoChangeOrangenessIfNeeded]; + [defaults synchronize]; } - (IBAction)colorChangingLocationSwitchValueChanged:(UISwitch *)sender { + NSUserDefaults *defaults = [NSUserDefaults groupDefaults]; + if(sender.on) { - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"updateUI"]; + [defaults setBool:NO forKey:@"updateUI"]; BOOL requestedLocationAuthorization = NO; if([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) { @@ -167,8 +177,8 @@ - (IBAction)colorChangingLocationSwitchValueChanged:(UISwitch *)sender { CGFloat latitude = self.locationManager.location.coordinate.latitude; CGFloat longitude = self.locationManager.location.coordinate.longitude; if (latitude != 0 && longitude != 0) { // make sure the location is available - [[NSUserDefaults standardUserDefaults] setFloat:latitude forKey:@"colorChangingLocationLatitude"]; - [[NSUserDefaults standardUserDefaults] setFloat:longitude forKey:@"colorChangingLocationLongitude"]; + [defaults setFloat:latitude forKey:@"colorChangingLocationLatitude"]; + [defaults setFloat:longitude forKey:@"colorChangingLocationLongitude"]; } [colorChangingEnabledSwitch setOn:NO animated:YES]; @@ -176,8 +186,8 @@ - (IBAction)colorChangingLocationSwitchValueChanged:(UISwitch *)sender { for(UITableViewCell *cell in timeBasedInputCells) [[cell contentView] setAlpha: .6]; - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"colorChangingLocationEnabled"]; - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"colorChangingEnabled"]; + [defaults setBool:YES forKey:@"colorChangingLocationEnabled"]; + [defaults setBool:NO forKey:@"colorChangingEnabled"]; } else if(!requestedLocationAuthorization) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No access to location" @@ -188,17 +198,21 @@ - (IBAction)colorChangingLocationSwitchValueChanged:(UISwitch *)sender { [alert show]; [sender setOn:NO animated:YES]; } - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"updateUI"]; + [defaults setBool:YES forKey:@"updateUI"]; [GammaController autoChangeOrangenessIfNeeded]; } else { - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"colorChangingLocationEnabled"]; + [defaults setBool:NO forKey:@"colorChangingLocationEnabled"]; } + + [defaults synchronize]; } - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { if (status == kCLAuthorizationStatusDenied) { [colorChangingLocationBasedSwitch setOn:NO animated:YES]; - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"colorChangingLocationEnabled"]; + NSUserDefaults *defaults = [NSUserDefaults groupDefaults]; + [defaults setBool:NO forKey:@"colorChangingLocationEnabled"]; + [defaults synchronize]; } else if (status == kCLAuthorizationStatusAuthorizedWhenInUse) { // revaluate the UISwitch status [self colorChangingLocationSwitchValueChanged: colorChangingLocationBasedSwitch]; @@ -238,16 +252,17 @@ - (void)timePickerValueChanged:(UIDatePicker*)picker { NSDateComponents *components = [[NSCalendar currentCalendar] components:(NSCalendarUnitHour | NSCalendarUnitMinute) fromDate:picker.date]; currentField.text = [timeFormatter stringFromDate:picker.date]; - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSUserDefaults *defaults = [NSUserDefaults groupDefaults]; [defaults setInteger:components.hour forKey:[defaultsKeyPrefix stringByAppendingString:@"Hour"]]; [defaults setInteger:components.minute forKey:[defaultsKeyPrefix stringByAppendingString:@"Minute"]]; [defaults setObject:[NSDate distantPast] forKey:@"lastAutoChangeDate"]; [GammaController autoChangeOrangenessIfNeeded]; + [defaults synchronize]; } - (void)textFieldDidBeginEditing:(UITextField *)textField { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSUserDefaults *defaults = [NSUserDefaults groupDefaults]; NSDate *date = nil; if (textField == startTimeTextField) { date = [self dateForHour:[defaults integerForKey:@"autoStartHour"] andMinute:[defaults integerForKey:@"autoStartMinute"]]; @@ -267,8 +282,9 @@ - (NSDate*)dateForHour:(NSInteger)hour andMinute:(NSInteger)minute{ } - (void)userDefaultsChanged:(NSNotification *)notification { - if([[NSUserDefaults standardUserDefaults] boolForKey:@"updateUI"]) + if ([[NSUserDefaults groupDefaults] boolForKey:@"updateUI"]) { [self updateUI]; + } } @end diff --git a/GammaTest/extentions/NSUserDefaults+Group.h b/GammaTest/extentions/NSUserDefaults+Group.h new file mode 100644 index 0000000..2d293db --- /dev/null +++ b/GammaTest/extentions/NSUserDefaults+Group.h @@ -0,0 +1,19 @@ +// +// NSUserDefaults+Group.h +// GammaTest +// +// Created by Arthur Hammer on 28.10.15. +// Copyright © 2015 Thomas Finch. All rights reserved. +// + +#import + +@interface NSUserDefaults (Group) + +// Returns a new NSUserDefaults object for app groups to share defaults in multiple targets. +// The suit name is the bundles' "AppGroupIdentifier" key. +// +// (Note: For now, this returns a new instance on every call.) ++ (NSUserDefaults *)groupDefaults; + +@end diff --git a/GammaTest/extentions/NSUserDefaults+Group.m b/GammaTest/extentions/NSUserDefaults+Group.m new file mode 100644 index 0000000..906ed12 --- /dev/null +++ b/GammaTest/extentions/NSUserDefaults+Group.m @@ -0,0 +1,18 @@ +// +// NSUserDefaults+Group.m +// GammaTest +// +// Created by Arthur Hammer on 28.10.15. +// Copyright © 2015 Thomas Finch. All rights reserved. +// + +#import "NSUserDefaults+Group.h" + +@implementation NSUserDefaults (Group) + ++ (NSUserDefaults *)groupDefaults { + NSString *suitName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppGroupIdentifier"]; + return [[NSUserDefaults alloc] initWithSuiteName:suitName]; +} + +@end diff --git a/GammaTest/mvc/controller/GammaController.m b/GammaTest/mvc/controller/GammaController.m index ab51715..16855f2 100644 --- a/GammaTest/mvc/controller/GammaController.m +++ b/GammaTest/mvc/controller/GammaController.m @@ -19,6 +19,7 @@ #import "solar.h" #import "brightness.h" #import "NSDate_compare.h" +#import "NSUserDefaults+Group.h" typedef void *IOMobileFramebufferRef; @@ -108,10 +109,23 @@ + (void)setGammaWithRed:(float)red green:(float)green blue:(float)blue { uint32_t data[0xc0c / sizeof(uint32_t)]; memset(data, 0, sizeof(data)); + // Hack to share a single gammatable.dat file between host app and Today widget. + // Otherwise, it can happen that the widget initializes its gammatable.dat with the existing gamma + // from the host app instead of the default screen values (or vice versa). In that case, the widget + // won't be able to fully turn off gamma. + // + // Issues: + // - Not thread-safe. The file is written only once, but still. + // - Tying the GammaController to app group logic makes it less general. + NSFileManager* fileManager = [NSFileManager defaultManager]; + NSString *suitName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppGroupIdentifier"]; + NSURL* containerURL = [fileManager containerURLForSecurityApplicationGroupIdentifier:suitName]; + NSString* filePath = [[containerURL path] stringByAppendingString:@"/gammatable.dat"]; + //Create the path string pointing to the temporary gamma table file - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); - NSString *documentsDirectory = [paths objectAtIndex:0]; - NSString *filePath = [documentsDirectory stringByAppendingString:@"/gammatable.dat"]; + //NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + //NSString *documentsDirectory = [paths objectAtIndex:0]; + //NSString *filePath = [documentsDirectory stringByAppendingString:@"/gammatable.dat"]; FILE *file = fopen([filePath UTF8String], "rb"); if (file == NULL) { @@ -194,7 +208,7 @@ + (void)setGammaWithTransitionFrom:(float)oldPercentOrange to:(float)newPercentO } + (void)enableOrangeness { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSUserDefaults *defaults = [NSUserDefaults groupDefaults]; // Making sure orangeness is not enabled if(![defaults boolForKey:@"enabled"]){ @@ -208,7 +222,7 @@ + (void)enableOrangeness { } + (void)disableOrangeness { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSUserDefaults *defaults = [NSUserDefaults groupDefaults]; // Making sure orangeness is not disabled if([defaults boolForKey:@"enabled"]){ @@ -233,7 +247,7 @@ + (bool)wakeUpScreenIfNeeded { } + (void) autoChangeOrangenessIfNeeded { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSUserDefaults *defaults = [NSUserDefaults groupDefaults]; // Reboot persistence check if (firstExecution) { @@ -335,10 +349,11 @@ + (void)switchScreenTemperatureBasedOnTime:(NSUserDefaults*)defaults { } [defaults setObject:[NSDate date] forKey:@"lastAutoChangeDate"]; + [defaults synchronize]; } + (BOOL)enabled { - NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; + NSUserDefaults* defaults = [NSUserDefaults groupDefaults]; return [defaults boolForKey:@"enabled"]; } diff --git a/GammaWidget/Base.lproj/MainInterface.storyboard b/GammaWidget/Base.lproj/MainInterface.storyboard new file mode 100644 index 0000000..2b28818 --- /dev/null +++ b/GammaWidget/Base.lproj/MainInterface.storyboard @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GammaWidget/GammaWidget.entitlements b/GammaWidget/GammaWidget.entitlements new file mode 100644 index 0000000..46da1a6 --- /dev/null +++ b/GammaWidget/GammaWidget.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.me.ahammer.GammaTest + + + diff --git a/GammaWidget/Info.plist b/GammaWidget/Info.plist new file mode 100644 index 0000000..7314e5c --- /dev/null +++ b/GammaWidget/Info.plist @@ -0,0 +1,35 @@ + + + + + AppGroupIdentifier + $(APP_GROUP_IDENTIFIER) + CFBundleDevelopmentRegion + en + CFBundleDisplayName + Gamma Thingy + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + NSExtension + + NSExtensionMainStoryboard + MainInterface + NSExtensionPointIdentifier + com.apple.widget-extension + + + diff --git a/GammaWidget/TodayViewController.h b/GammaWidget/TodayViewController.h new file mode 100644 index 0000000..7a147a9 --- /dev/null +++ b/GammaWidget/TodayViewController.h @@ -0,0 +1,13 @@ +// +// TodayViewController.h +// GammaWidget +// +// Created by Arthur Hammer on 27.10.15. +// Copyright © 2015 Thomas Finch. All rights reserved. +// + +#import + +@interface TodayViewController : UIViewController + +@end diff --git a/GammaWidget/TodayViewController.m b/GammaWidget/TodayViewController.m new file mode 100644 index 0000000..5cf226d --- /dev/null +++ b/GammaWidget/TodayViewController.m @@ -0,0 +1,117 @@ +// +// TodayViewController.m +// GammaWidget +// +// Created by Arthur Hammer on 27.10.15. +// Copyright © 2015 Thomas Finch. All rights reserved. +// + +#import "TodayViewController.h" +#import +#import "GammaController.h" +#import "NSUserDefaults+Group.h" + +@interface TodayViewController () +@property IBOutlet UIButton *toggleButton; +@property IBOutlet UIButton *increaseButton; +@property IBOutlet UIButton *decreaseButton; + +@property IBOutlet UIVisualEffectView *toggleView; +@property IBOutlet UIVisualEffectView *increaseView; +@property IBOutlet UIVisualEffectView *decreaseView; +@end + +@implementation TodayViewController + +float increaseOrangenessBy = 0.1f; + +- (void)viewDidLoad { + [super viewDidLoad]; + self.preferredContentSize = CGSizeMake(0, 33); + + self.toggleView.layer.cornerRadius = 5; + self.increaseView.layer.cornerRadius = 5; + self.decreaseView.layer.cornerRadius = 5; + + self.toggleView.clipsToBounds = YES; + self.increaseView.clipsToBounds = YES; + self.decreaseView.clipsToBounds = YES; + NSString *defaultsPath = [[NSBundle mainBundle] pathForResource:@"Defaults" ofType:@"plist"]; + NSDictionary *appDefaults = [NSDictionary dictionaryWithContentsOfFile:defaultsPath]; + [[NSUserDefaults groupDefaults] registerDefaults:appDefaults]; +} + +- (void)viewWillAppear:(BOOL)animated { + [GammaController autoChangeOrangenessIfNeeded]; + [self updateUI]; +} + +- (void)updateUI { + BOOL enabled = [[NSUserDefaults groupDefaults] boolForKey:@"enabled"]; + self.toggleButton.selected = enabled; + self.increaseButton.enabled = enabled; + self.decreaseButton.enabled = enabled; +} + +- (UIEdgeInsets)widgetMarginInsetsForProposedMarginInsets:(UIEdgeInsets)defaultMarginInsets { + return UIEdgeInsetsMake(10, defaultMarginInsets.left, 10, defaultMarginInsets.right); +} + +- (IBAction)toggle:(id)sender { + if ([[NSUserDefaults groupDefaults] boolForKey:@"enabled"]) { + [GammaController disableOrangeness]; + } else { + [GammaController enableOrangeness]; + } + [self updateUI]; +} + +- (IBAction)increase:(id)sender { + NSUserDefaults *defaults = [NSUserDefaults groupDefaults]; + + if ([defaults boolForKey:@"enabled"]) { + float intensity = [defaults floatForKey:@"maxOrange"]; + float newIntensity = intensity + increaseOrangenessBy; + newIntensity = newIntensity >= 1 ? 1 : newIntensity; + [GammaController setGammaWithTransitionFrom:intensity to:newIntensity]; + // This should be somewhere else, no? + [defaults setFloat:newIntensity forKey:@"maxOrange"]; + [defaults synchronize]; + [self updateUI]; + } +} + +- (IBAction)decrease:(id)sender { + NSUserDefaults *defaults = [NSUserDefaults groupDefaults]; + + if ([defaults boolForKey:@"enabled"]) { + float intensity = [defaults floatForKey:@"maxOrange"]; + float newIntensity = intensity - increaseOrangenessBy; + newIntensity = newIntensity <= 0 ? 0 : newIntensity; + [GammaController setGammaWithTransitionFrom:intensity to:newIntensity]; + // This should be somewhere else, no? + [defaults setFloat:newIntensity forKey:@"maxOrange"]; + [defaults synchronize]; + [self updateUI]; + } +} + +- (IBAction)openApp:(id)sender { + [[self extensionContext] openURL:[NSURL URLWithString:@"gammathingy://"] completionHandler:nil]; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} + +- (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler { + NSUserDefaults *defaults = [NSUserDefaults groupDefaults]; + BOOL enabledOnLastCheck = [defaults boolForKey:@"widgetLastCheckEnabled"]; + BOOL enabled = [defaults boolForKey:@"enabled"]; + [defaults setBool:enabled forKey:@"widgetLastCheckEnabled"]; + [defaults synchronize]; + + completionHandler(enabledOnLastCheck != enabled ? NCUpdateResultNewData : NCUpdateResultNoData); +} + +@end