From 21e64f961dbef18da4a7caadeca63a7c8215af4e Mon Sep 17 00:00:00 2001 From: Muukii Date: Tue, 6 Apr 2021 23:20:12 +0900 Subject: [PATCH] Add extensions --- Brightroom.xcodeproj/project.pbxproj | 279 ++++++++++++++++++ Import LUT/Action.js | 43 +++ Import LUT/ActionRequestHandler.swift | 90 ++++++ Import LUT/Info.plist | 59 ++++ Import LUT/Media.xcassets/Contents.json | 6 + .../TouchBarBezel.colorset/Contents.json | 14 + ShareLUT/Base.lproj/MainInterface.storyboard | 24 ++ ShareLUT/Info.plist | 36 +++ ShareLUT/ShareViewController.swift | 31 ++ Sources/Demo/Info.plist | 69 ++++- 10 files changed, 647 insertions(+), 4 deletions(-) create mode 100644 Import LUT/Action.js create mode 100644 Import LUT/ActionRequestHandler.swift create mode 100644 Import LUT/Info.plist create mode 100644 Import LUT/Media.xcassets/Contents.json create mode 100644 Import LUT/Media.xcassets/TouchBarBezel.colorset/Contents.json create mode 100644 ShareLUT/Base.lproj/MainInterface.storyboard create mode 100644 ShareLUT/Info.plist create mode 100644 ShareLUT/ShareViewController.swift diff --git a/Brightroom.xcodeproj/project.pbxproj b/Brightroom.xcodeproj/project.pbxproj index 1671f35b..28d35006 100644 --- a/Brightroom.xcodeproj/project.pbxproj +++ b/Brightroom.xcodeproj/project.pbxproj @@ -195,6 +195,13 @@ 4BE9B3D2260BA769000A3D09 /* gaku.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = 4BF23C312603BCE0007019CB /* gaku.jpeg */; }; 4BE9B3E1260BA77C000A3D09 /* Bundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BE9B3D9260BA778000A3D09 /* Bundle.swift */; }; 4BEC14BE2603ADDB009CE218 /* EditingCrop+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BEC14BD2603ADDB009CE218 /* EditingCrop+.swift */; }; + 4BED49CB261C9BBD0011A98F /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4BED49CA261C9BBD0011A98F /* Media.xcassets */; }; + 4BED49CD261C9BBD0011A98F /* ActionRequestHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BED49CC261C9BBD0011A98F /* ActionRequestHandler.swift */; }; + 4BED49CF261C9BBD0011A98F /* Action.js in Resources */ = {isa = PBXBuildFile; fileRef = 4BED49CE261C9BBD0011A98F /* Action.js */; }; + 4BED49D3261C9BBD0011A98F /* Import LUT.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 4BED49C8261C9BBD0011A98F /* Import LUT.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 4BED49E3261C9CE20011A98F /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BED49E2261C9CE20011A98F /* ShareViewController.swift */; }; + 4BED49E6261C9CE20011A98F /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4BED49E4261C9CE20011A98F /* MainInterface.storyboard */; }; + 4BED49EA261C9CE20011A98F /* ShareLUT.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 4BED49E0261C9CE20011A98F /* ShareLUT.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 4BEE650B217479C600F3578E /* BlurredMask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B0077BD2170496E008330EA /* BlurredMask.swift */; }; 4BEE650C217479C600F3578E /* OvalBrush.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B9B030B216C55D9001593B9 /* OvalBrush.swift */; }; 4BEE650D217479C600F3578E /* DrawnPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B9B030D216C58C6001593B9 /* DrawnPath.swift */; }; @@ -255,6 +262,20 @@ remoteGlobalIDString = 4B600AFC216B7A94001E1456; remoteInfo = PixelEngine; }; + 4BED49D1261C9BBD0011A98F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4B600AF4216B7A94001E1456 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 4BED49C7261C9BBD0011A98F; + remoteInfo = "Import LUT"; + }; + 4BED49E8261C9CE20011A98F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4B600AF4216B7A94001E1456 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 4BED49DF261C9CE20011A98F; + remoteInfo = ShareLUT; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -282,6 +303,18 @@ name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; }; + 4BED49D7261C9BBD0011A98F /* Embed App Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 4BED49EA261C9CE20011A98F /* ShareLUT.appex in Embed App Extensions */, + 4BED49D3261C9BBD0011A98F /* Import LUT.appex in Embed App Extensions */, + ); + name = "Embed App Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -456,6 +489,15 @@ 4BE9B3C4260BA641000A3D09 /* LoadingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingTests.swift; sourceTree = ""; }; 4BE9B3D9260BA778000A3D09 /* Bundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bundle.swift; sourceTree = ""; }; 4BEC14BD2603ADDB009CE218 /* EditingCrop+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EditingCrop+.swift"; sourceTree = ""; }; + 4BED49C8261C9BBD0011A98F /* Import LUT.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Import LUT.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; + 4BED49CA261C9BBD0011A98F /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = ""; }; + 4BED49CC261C9BBD0011A98F /* ActionRequestHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionRequestHandler.swift; sourceTree = ""; }; + 4BED49CE261C9BBD0011A98F /* Action.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = Action.js; sourceTree = ""; }; + 4BED49D0261C9BBD0011A98F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 4BED49E0261C9CE20011A98F /* ShareLUT.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = ShareLUT.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + 4BED49E2261C9CE20011A98F /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = ""; }; + 4BED49E5261C9CE20011A98F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; + 4BED49E7261C9CE20011A98F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 4BEE65102174DC3800F3578E /* EditorLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorLog.swift; sourceTree = ""; }; 4BEE65122174E99600F3578E /* EngineLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EngineLog.swift; sourceTree = ""; }; 4BF0255F25F12FE30093A59B /* SwiftUICropView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUICropView.swift; sourceTree = ""; }; @@ -524,6 +566,20 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 4BED49C5261C9BBD0011A98F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 4BED49DD261C9CE20011A98F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -724,6 +780,8 @@ 4B4C7C8E260A6EF70082240A /* Archives */, 4B6A5F5B2179D43A004D68DC /* Sources */, 4BDEE0A625F8CF6800FA22CB /* Tests */, + 4BED49C9261C9BBD0011A98F /* Import LUT */, + 4BED49E1261C9CE20011A98F /* ShareLUT */, 4B600AFE216B7A94001E1456 /* Products */, 4B600B37216B7CD6001E1456 /* Frameworks */, 8B5AF77CCD85658D372FF477 /* Pods */, @@ -740,6 +798,8 @@ 4B47D052216CC5350007B594 /* BrightroomUI.framework */, 4B98CCB925EFF31300E4F61F /* SwiftUIDemo.app */, 4BDEE09825F8CF5800FA22CB /* BrightroomEngineTests.xctest */, + 4BED49C8261C9BBD0011A98F /* Import LUT.appex */, + 4BED49E0261C9CE20011A98F /* ShareLUT.appex */, ); name = Products; sourceTree = ""; @@ -989,6 +1049,27 @@ path = Bundle; sourceTree = ""; }; + 4BED49C9261C9BBD0011A98F /* Import LUT */ = { + isa = PBXGroup; + children = ( + 4BED49CA261C9BBD0011A98F /* Media.xcassets */, + 4BED49CC261C9BBD0011A98F /* ActionRequestHandler.swift */, + 4BED49CE261C9BBD0011A98F /* Action.js */, + 4BED49D0261C9BBD0011A98F /* Info.plist */, + ); + path = "Import LUT"; + sourceTree = ""; + }; + 4BED49E1261C9CE20011A98F /* ShareLUT */ = { + isa = PBXGroup; + children = ( + 4BED49E2261C9CE20011A98F /* ShareViewController.swift */, + 4BED49E4261C9CE20011A98F /* MainInterface.storyboard */, + 4BED49E7261C9CE20011A98F /* Info.plist */, + ); + path = ShareLUT; + sourceTree = ""; + }; 4BEEFF1B25E6827B008144EA /* ClassicImageEdit */ = { isa = PBXGroup; children = ( @@ -1097,12 +1178,15 @@ 4B600B1E216B7C9C001E1456 /* Resources */, 4B600B36216B7CB4001E1456 /* Embed Frameworks */, E0F739463B049CD93AAA763E /* [CP] Embed Pods Frameworks */, + 4BED49D7261C9BBD0011A98F /* Embed App Extensions */, ); buildRules = ( ); dependencies = ( 4B600B35216B7CB4001E1456 /* PBXTargetDependency */, 4B47D058216CC5350007B594 /* PBXTargetDependency */, + 4BED49D2261C9BBD0011A98F /* PBXTargetDependency */, + 4BED49E9261C9CE20011A98F /* PBXTargetDependency */, ); name = Demo; productName = Demo; @@ -1149,6 +1233,40 @@ productReference = 4BDEE09825F8CF5800FA22CB /* BrightroomEngineTests.xctest */; productType = "com.apple.product-type.bundle.ui-testing"; }; + 4BED49C7261C9BBD0011A98F /* Import LUT */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4BED49D4261C9BBD0011A98F /* Build configuration list for PBXNativeTarget "Import LUT" */; + buildPhases = ( + 4BED49C4261C9BBD0011A98F /* Sources */, + 4BED49C5261C9BBD0011A98F /* Frameworks */, + 4BED49C6261C9BBD0011A98F /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Import LUT"; + productName = "Import LUT"; + productReference = 4BED49C8261C9BBD0011A98F /* Import LUT.appex */; + productType = "com.apple.product-type.app-extension"; + }; + 4BED49DF261C9CE20011A98F /* ShareLUT */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4BED49EB261C9CE20011A98F /* Build configuration list for PBXNativeTarget "ShareLUT" */; + buildPhases = ( + 4BED49DC261C9CE20011A98F /* Sources */, + 4BED49DD261C9CE20011A98F /* Frameworks */, + 4BED49DE261C9CE20011A98F /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ShareLUT; + productName = ShareLUT; + productReference = 4BED49E0261C9CE20011A98F /* ShareLUT.appex */; + productType = "com.apple.product-type.app-extension"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -1177,6 +1295,12 @@ 4BDEE09725F8CF5800FA22CB = { CreatedOnToolsVersion = 12.4; }; + 4BED49C7261C9BBD0011A98F = { + CreatedOnToolsVersion = 12.4; + }; + 4BED49DF261C9CE20011A98F = { + CreatedOnToolsVersion = 12.4; + }; }; }; buildConfigurationList = 4B600AF7216B7A94001E1456 /* Build configuration list for PBXProject "Brightroom" */; @@ -1201,6 +1325,8 @@ 4BDEE09725F8CF5800FA22CB /* BrightroomEngineTests */, 4B600B1F216B7C9C001E1456 /* Demo */, 4B98CCB825EFF31300E4F61F /* SwiftUIDemo */, + 4BED49C7261C9BBD0011A98F /* Import LUT */, + 4BED49DF261C9CE20011A98F /* ShareLUT */, ); }; /* End PBXProject section */ @@ -1300,6 +1426,23 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 4BED49C6261C9BBD0011A98F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4BED49CF261C9BBD0011A98F /* Action.js in Resources */, + 4BED49CB261C9BBD0011A98F /* Media.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 4BED49DE261C9CE20011A98F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4BED49E6261C9CE20011A98F /* MainInterface.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -1549,6 +1692,22 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 4BED49C4261C9BBD0011A98F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4BED49CD261C9BBD0011A98F /* ActionRequestHandler.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 4BED49DC261C9CE20011A98F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4BED49E3261C9CE20011A98F /* ShareViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -1577,6 +1736,16 @@ target = 4B600AFC216B7A94001E1456 /* BrightroomEngine */; targetProxy = 4BDEE24D25F8D19D00FA22CB /* PBXContainerItemProxy */; }; + 4BED49D2261C9BBD0011A98F /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 4BED49C7261C9BBD0011A98F /* Import LUT */; + targetProxy = 4BED49D1261C9BBD0011A98F /* PBXContainerItemProxy */; + }; + 4BED49E9261C9CE20011A98F /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 4BED49DF261C9CE20011A98F /* ShareLUT */; + targetProxy = 4BED49E8261C9CE20011A98F /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -1588,6 +1757,14 @@ name = LaunchScreen.storyboard; sourceTree = ""; }; + 4BED49E4261C9CE20011A98F /* MainInterface.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 4BED49E5261C9CE20011A98F /* Base */, + ); + name = MainInterface.storyboard; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -1956,6 +2133,90 @@ }; name = Release; }; + 4BED49D5261C9BBD0011A98F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = KU2QEJ9K3Z; + INFOPLIST_FILE = "Import LUT/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 14.4; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "app.muukii.brightroom.Demo.Import-LUT"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 4BED49D6261C9BBD0011A98F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = KU2QEJ9K3Z; + INFOPLIST_FILE = "Import LUT/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 14.4; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "app.muukii.brightroom.Demo.Import-LUT"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 4BED49EC261C9CE20011A98F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = KU2QEJ9K3Z; + INFOPLIST_FILE = ShareLUT/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.4; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = app.muukii.brightroom.Demo.ShareLUT; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 4BED49ED261C9CE20011A98F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = KU2QEJ9K3Z; + INFOPLIST_FILE = ShareLUT/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.4; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = app.muukii.brightroom.Demo.ShareLUT; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -2013,6 +2274,24 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 4BED49D4261C9BBD0011A98F /* Build configuration list for PBXNativeTarget "Import LUT" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4BED49D5261C9BBD0011A98F /* Debug */, + 4BED49D6261C9BBD0011A98F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4BED49EB261C9CE20011A98F /* Build configuration list for PBXNativeTarget "ShareLUT" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4BED49EC261C9CE20011A98F /* Debug */, + 4BED49ED261C9CE20011A98F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ diff --git a/Import LUT/Action.js b/Import LUT/Action.js new file mode 100644 index 00000000..f1482ada --- /dev/null +++ b/Import LUT/Action.js @@ -0,0 +1,43 @@ +// +// Action.js +// Import LUT +// +// Created by Muukii on 2021/04/06. +// Copyright © 2021 muukii. All rights reserved. +// + +var Action = function() {}; + +Action.prototype = { + + run: function(arguments) { + // Here, you can run code that modifies the document and/or prepares + // things to pass to your action's native code. + + // We will not modify anything, but will pass the body's background + // style to the native code. + + arguments.completionFunction({ "currentBackgroundColor" : document.body.style.backgroundColor }) + }, + + finalize: function(arguments) { + // This method is run after the native code completes. + + // We'll see if the native code has passed us a new background style, + // and set it on the body. + + var newBackgroundColor = arguments["newBackgroundColor"] + if (newBackgroundColor) { + // We'll set document.body.style.background, to override any + // existing background. + document.body.style.background = newBackgroundColor + } else { + // If nothing's been returned to us, we'll set the background to + // blue. + document.body.style.background= "blue" + } + } + +}; + +var ExtensionPreprocessingJS = new Action diff --git a/Import LUT/ActionRequestHandler.swift b/Import LUT/ActionRequestHandler.swift new file mode 100644 index 00000000..26f41d39 --- /dev/null +++ b/Import LUT/ActionRequestHandler.swift @@ -0,0 +1,90 @@ +// +// ActionRequestHandler.swift +// Import LUT +// +// Created by Muukii on 2021/04/06. +// Copyright © 2021 muukii. All rights reserved. +// + +import UIKit +import MobileCoreServices + +class ActionRequestHandler: NSObject, NSExtensionRequestHandling { + + var extensionContext: NSExtensionContext? + + func beginRequest(with context: NSExtensionContext) { + // Do not call super in an Action extension with no user interface +// self.extensionContext = context + + var found = false + + // Find the item containing the results from the JavaScript preprocessing. + outer: + for item in context.inputItems as! [NSExtensionItem] { + if let attachments = item.attachments { + for itemProvider in attachments { + if itemProvider.hasItemConformingToTypeIdentifier(String(kUTTypePropertyList)) { + itemProvider.loadItem(forTypeIdentifier: String(kUTTypePropertyList), options: nil, completionHandler: { (item, error) in + let dictionary = item as! [String: Any] + OperationQueue.main.addOperation { + self.itemLoadCompletedWithPreprocessingResults(dictionary[NSExtensionJavaScriptPreprocessingResultsKey] as! [String: Any]? ?? [:]) + } + }) + found = true + break outer + } + } + } + } + + if !found { + self.doneWithResults(nil) + } + } + + func itemLoadCompletedWithPreprocessingResults(_ javaScriptPreprocessingResults: [String: Any]) { + // Here, do something, potentially asynchronously, with the preprocessing + // results. + + // In this very simple example, the JavaScript will have passed us the + // current background color style, if there is one. We will construct a + // dictionary to send back with a desired new background color style. + let bgColor: Any? = javaScriptPreprocessingResults["currentBackgroundColor"] + if bgColor == nil || bgColor! as! String == "" { + // No specific background color? Request setting the background to red. + self.doneWithResults(["newBackgroundColor": "red"]) + } else { + // Specific background color is set? Request replacing it with green. + self.doneWithResults(["newBackgroundColor": "green"]) + } + } + + func doneWithResults(_ resultsForJavaScriptFinalizeArg: [String: Any]?) { + if let resultsForJavaScriptFinalize = resultsForJavaScriptFinalizeArg { + // Construct an NSExtensionItem of the appropriate type to return our + // results dictionary in. + + // These will be used as the arguments to the JavaScript finalize() + // method. + + let resultsDictionary = [NSExtensionJavaScriptFinalizeArgumentKey: resultsForJavaScriptFinalize] + + let resultsProvider = NSItemProvider(item: resultsDictionary as NSDictionary, typeIdentifier: String(kUTTypePropertyList)) + + let resultsItem = NSExtensionItem() + resultsItem.attachments = [resultsProvider] + + // Signal that we're complete, returning our results. + self.extensionContext!.completeRequest(returningItems: [resultsItem], completionHandler: nil) + } else { + // We still need to signal that we're done even if we have nothing to + // pass back. + self.extensionContext!.completeRequest(returningItems: [], completionHandler: nil) + } + + // Don't hold on to this after we finished with it. + self.extensionContext = nil + } + +} diff --git a/Import LUT/Info.plist b/Import LUT/Info.plist new file mode 100644 index 00000000..ebd5055c --- /dev/null +++ b/Import LUT/Info.plist @@ -0,0 +1,59 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Import LUT + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + NSExtension + + NSExtensionAttributes + + NSExtensionActivationRule + + NSExtensionActivationSupportsFileWithMaxCount + 0 + NSExtensionActivationSupportsImageWithMaxCount + 10 + NSExtensionActivationSupportsMovieWithMaxCount + 0 + NSExtensionActivationSupportsText + + NSExtensionActivationSupportsWebURLWithMaxCount + 1 + + NSExtensionJavaScriptPreprocessingFile + Action + NSExtensionServiceAllowsFinderPreviewItem + + NSExtensionServiceAllowsTouchBarItem + + NSExtensionServiceFinderPreviewIconName + NSActionTemplate + NSExtensionServiceTouchBarBezelColorName + TouchBarBezel + NSExtensionServiceTouchBarIconName + NSActionTemplate + + NSExtensionPointIdentifier + com.apple.services + NSExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).ActionRequestHandler + + + diff --git a/Import LUT/Media.xcassets/Contents.json b/Import LUT/Media.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/Import LUT/Media.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Import LUT/Media.xcassets/TouchBarBezel.colorset/Contents.json b/Import LUT/Media.xcassets/TouchBarBezel.colorset/Contents.json new file mode 100644 index 00000000..94a9fc21 --- /dev/null +++ b/Import LUT/Media.xcassets/TouchBarBezel.colorset/Contents.json @@ -0,0 +1,14 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "mac", + "color" : { + "reference" : "systemPurpleColor" + } + } + ] +} \ No newline at end of file diff --git a/ShareLUT/Base.lproj/MainInterface.storyboard b/ShareLUT/Base.lproj/MainInterface.storyboard new file mode 100644 index 00000000..286a5089 --- /dev/null +++ b/ShareLUT/Base.lproj/MainInterface.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ShareLUT/Info.plist b/ShareLUT/Info.plist new file mode 100644 index 00000000..4d11a0ed --- /dev/null +++ b/ShareLUT/Info.plist @@ -0,0 +1,36 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + ShareLUT + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + NSExtension + + NSExtensionAttributes + + NSExtensionActivationRule + TRUEPREDICATE + + NSExtensionMainStoryboard + MainInterface + NSExtensionPointIdentifier + com.apple.share-services + + + diff --git a/ShareLUT/ShareViewController.swift b/ShareLUT/ShareViewController.swift new file mode 100644 index 00000000..252c1e90 --- /dev/null +++ b/ShareLUT/ShareViewController.swift @@ -0,0 +1,31 @@ +// +// ShareViewController.swift +// ShareLUT +// +// Created by Muukii on 2021/04/06. +// Copyright © 2021 muukii. All rights reserved. +// + +import UIKit +import Social + +class ShareViewController: SLComposeServiceViewController { + + override func isContentValid() -> Bool { + // Do validation of contentText and/or NSExtensionContext attachments here + return true + } + + override func didSelectPost() { + // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments. + + // Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context. + self.extensionContext!.completeRequest(returningItems: [], completionHandler: nil) + } + + override func configurationItems() -> [Any]! { + // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here. + return [] + } + +} diff --git a/Sources/Demo/Info.plist b/Sources/Demo/Info.plist index 34052c2f..6161405e 100644 --- a/Sources/Demo/Info.plist +++ b/Sources/Demo/Info.plist @@ -2,12 +2,25 @@ - NSCameraUsageDescription - For demo - UIUserInterfaceStyle - Light CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) + CFBundleDocumentTypes + + + CFBundleTypeIconFiles + + CGBundleTypeRole + Viewer + CFBundleTypeName + LUT + LSHandlerRank + Owner + LSItemContentTypes + + app.muukii.brightroom + + + CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -24,6 +37,8 @@ 1 LSRequiresIPhoneOS + NSCameraUsageDescription + For demo NSPhotoLibraryUsageDescription ... UIApplicationSceneManifest @@ -51,5 +66,51 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIUserInterfaceStyle + Light + UTExportedTypeDeclarations + + + UTTypeConformsTo + + public.data + + UTTypeDescription + Import LUT + UTTypeIconFiles + + UTTypeIdentifier + app.muukii.brightroom + UTTypeTagSpecification + + + + UTImportedTypeDeclarations + + + UILaunchImageFile + + UTTypeConformsTo + + public.data + + UTTypeDescription + Import LUT + UTTypeIconFiles + + UTTypeIdentifier + app.muukii.brightroom.Demo + UTTypeTagSpecification + + public.filename-extension + + jpeg + png + jpg + + + + +