From 2b35db02ae1f41137b379fd0280aada2b9a071b9 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Wed, 15 Jul 2020 16:29:15 -0400 Subject: [PATCH] [Accessibility] Add new Framework from Xcode 12 beta 1. (#9086) Co-authored-by: Rolf Bjarne Kvinge --- src/Constants.iOS.cs.in | 1 + src/Constants.mac.cs.in | 5 +- src/Constants.tvos.cs.in | 1 + src/Constants.watch.cs.in | 1 + src/CoreGraphics/CGColor.cs | 9 ++++ src/accessibility.cs | 53 +++++++++++++++++++ src/frameworks.sources | 1 + .../monotouch-test/CoreGraphics/ColorTest.cs | 9 ++++ tests/xtro-sharpie/iOS-Accessibility.todo | 12 ----- tests/xtro-sharpie/macOS-Accessibility.todo | 12 ----- tests/xtro-sharpie/tvOS-Accessibility.todo | 12 ----- tests/xtro-sharpie/watchOS-Accessibility.todo | 12 ----- tools/common/Frameworks.cs | 4 ++ tools/mtouch/Makefile | 1 + 14 files changed, 83 insertions(+), 50 deletions(-) create mode 100644 src/accessibility.cs delete mode 100644 tests/xtro-sharpie/iOS-Accessibility.todo delete mode 100644 tests/xtro-sharpie/macOS-Accessibility.todo delete mode 100644 tests/xtro-sharpie/tvOS-Accessibility.todo delete mode 100644 tests/xtro-sharpie/watchOS-Accessibility.todo diff --git a/src/Constants.iOS.cs.in b/src/Constants.iOS.cs.in index e42f0f725819..7c55aba301d6 100644 --- a/src/Constants.iOS.cs.in +++ b/src/Constants.iOS.cs.in @@ -145,6 +145,7 @@ namespace ObjCRuntime { // iOS 13.4 public const string AutomaticAssessmentConfigurationLibrary = "/System/Library/Frameworks/AutomaticAssessmentConfiguration.framework/AutomaticAssessmentConfiguration"; // iOS 14.0 + public const string AccessibilityLibrary = "/System/Library/Frameworks/Accessibility.framework/Accessibility"; public const string AppClipLibrary = "/System/Library/Frameworks/AppClip.framework/AppClip"; public const string UniformTypeIdentifiersLibrary = "/System/Library/Frameworks/UniformTypeIdentifiers.framework/UniformTypeIdentifiers"; } diff --git a/src/Constants.mac.cs.in b/src/Constants.mac.cs.in index 757d66a97ac1..223692020846 100644 --- a/src/Constants.mac.cs.in +++ b/src/Constants.mac.cs.in @@ -172,9 +172,10 @@ namespace ObjCRuntime { public const string AutomaticAssessmentConfigurationLibrary = "/System/Library/Frameworks/AutomaticAssessmentConfiguration.framework/AutomaticAssessmentConfiguration"; // macOS 10.16 - public const string UniformTypeIdentifiersLibrary = "/System/Library/Frameworks/UniformTypeIdentifiers.framework/UniformTypeIdentifiers"; - public const string UserNotificationsUILibrary = "/System/Library/Frameworks/UserNotificationsUI.framework/UserNotificationsUI"; + public const string AccessibilityLibrary = "/System/Library/Frameworks/Accessibility.framework/Accessibility"; public const string ClassKitLibrary = "/System/Library/Frameworks/ClassKit.framework/ClassKit"; public const string ReplayKitLibrary = "/System/Library/Frameworks/ReplayKit.framework/ReplayKit"; + public const string UniformTypeIdentifiersLibrary = "/System/Library/Frameworks/UniformTypeIdentifiers.framework/UniformTypeIdentifiers"; + public const string UserNotificationsUILibrary = "/System/Library/Frameworks/UserNotificationsUI.framework/UserNotificationsUI"; } } diff --git a/src/Constants.tvos.cs.in b/src/Constants.tvos.cs.in index e1a89f69d883..5d7d6f94d3bd 100644 --- a/src/Constants.tvos.cs.in +++ b/src/Constants.tvos.cs.in @@ -93,6 +93,7 @@ namespace ObjCRuntime { public const string BackgroundTasksLibrary = "/System/Library/Frameworks/BackgroundTasks.framework/BackgroundTasks"; // tvOS 14.0 + public const string AccessibilityLibrary = "/System/Library/Frameworks/Accessibility.framework/Accessibility"; public const string LinkPresentationLibrary = "/System/Library/Frameworks/LinkPresentation.framework/LinkPresentation"; public const string UniformTypeIdentifiersLibrary = "/System/Library/Frameworks/UniformTypeIdentifiers.framework/UniformTypeIdentifiers"; } diff --git a/src/Constants.watch.cs.in b/src/Constants.watch.cs.in index 696b23fb039b..9ef041f58f13 100644 --- a/src/Constants.watch.cs.in +++ b/src/Constants.watch.cs.in @@ -70,6 +70,7 @@ namespace ObjCRuntime { public const string StoreKitLibrary = "/System/Library/Frameworks/StoreKit.framework/StoreKit"; // watchOS 7 + public const string AccessibilityLibrary = "/System/Library/Frameworks/Accessibility.framework/Accessibility"; public const string UniformTypeIdentifiersLibrary = "/System/Library/Frameworks/UniformTypeIdentifiers.framework/UniformTypeIdentifiers"; } } diff --git a/src/CoreGraphics/CGColor.cs b/src/CoreGraphics/CGColor.cs index a23e47b628ce..2b655dc0e4f0 100644 --- a/src/CoreGraphics/CGColor.cs +++ b/src/CoreGraphics/CGColor.cs @@ -330,6 +330,15 @@ static public CGColor CreateCmyk (nfloat cyan, nfloat magenta, nfloat yellow, nf var h = CGColorCreateGenericCMYK (cyan, magenta, yellow, black, alpha); return h == IntPtr.Zero ? null : new CGColor (h, owns: true); } + + [iOS (14,0)][TV (14,0)][Watch (7,0)][Mac (10,16)] + [DllImport (Constants.AccessibilityLibrary)] + static extern /* NSString */ IntPtr AXNameFromColor (/* CGColorRef */ IntPtr color); + + [iOS (14,0)][TV (14,0)][Watch (7,0)][Mac (10,16)] + public string AXName => NSString.FromHandle (AXNameFromColor (handle)); + + #endif // !COREBUILD } } diff --git a/src/accessibility.cs b/src/accessibility.cs new file mode 100644 index 000000000000..0ee5d0ee718b --- /dev/null +++ b/src/accessibility.cs @@ -0,0 +1,53 @@ +using System; +using Foundation; +using ObjCRuntime; + +namespace Accessibility { + + [Watch (7, 0), TV (14, 0), Mac (10, 16), iOS (14, 0)] + [Native] + public enum AXCustomContentImportance : ulong + { + Default, + High, + } + + [Watch (7, 0), TV (14, 0), Mac (10, 16), iOS (14, 0)] + [BaseType (typeof (NSObject))] + [DisableDefaultCtor] + interface AXCustomContent : NSCopying, NSSecureCoding + { + [Static] + [Export ("customContentWithLabel:value:")] + AXCustomContent Create (string label, string value); + + [Static] + [Export ("customContentWithAttributedLabel:attributedValue:")] + AXCustomContent Create (NSAttributedString label, NSAttributedString value); + + [Export ("label")] + string Label { get; } + + [Export ("attributedLabel", ArgumentSemantic.Copy)] + NSAttributedString AttributedLabel { get; } + + [Export ("value")] + string Value { get; } + + [Export ("attributedValue", ArgumentSemantic.Copy)] + NSAttributedString AttributedValue { get; } + + [Export ("importance", ArgumentSemantic.Assign)] + AXCustomContentImportance Importance { get; set; } + } + + [Watch (7, 0), TV (14, 0), Mac (10, 16), iOS (14, 0)] + [Protocol] + interface AXCustomContentProvider + { + [Abstract] + [NullAllowed, Export ("accessibilityCustomContent", ArgumentSemantic.Copy)] + AXCustomContent[] AccessibilityCustomContent { get; set; } + } + +} diff --git a/src/frameworks.sources b/src/frameworks.sources index 39aec6c3f82e..589121abe30f 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -1779,6 +1779,7 @@ SHARED_SOURCES = \ # COMMON_FRAMEWORKS = \ + Accessibility \ Accelerate \ AuthenticationServices \ AVFoundation \ diff --git a/tests/monotouch-test/CoreGraphics/ColorTest.cs b/tests/monotouch-test/CoreGraphics/ColorTest.cs index 2a1ef6d38a0a..4e583271eac8 100644 --- a/tests/monotouch-test/CoreGraphics/ColorTest.cs +++ b/tests/monotouch-test/CoreGraphics/ColorTest.cs @@ -98,6 +98,15 @@ public void Cmyk () } } + [Test] + public void GetAXName () + { + TestRuntime.AssertXcodeVersion (12, 0); + using (var c = new CGColor (CGConstantColor.Black)) { + Assert.IsNotNull (c.AXName, "AXName"); + } + } + } } diff --git a/tests/xtro-sharpie/iOS-Accessibility.todo b/tests/xtro-sharpie/iOS-Accessibility.todo deleted file mode 100644 index 81da6e6c90a4..000000000000 --- a/tests/xtro-sharpie/iOS-Accessibility.todo +++ /dev/null @@ -1,12 +0,0 @@ -!missing-enum! AXCustomContentImportance not bound -!missing-pinvoke! AXNameFromColor is not bound -!missing-protocol! AXCustomContentProvider not bound -!missing-selector! +AXCustomContent::customContentWithAttributedLabel:attributedValue: not bound -!missing-selector! +AXCustomContent::customContentWithLabel:value: not bound -!missing-selector! AXCustomContent::attributedLabel not bound -!missing-selector! AXCustomContent::attributedValue not bound -!missing-selector! AXCustomContent::importance not bound -!missing-selector! AXCustomContent::label not bound -!missing-selector! AXCustomContent::setImportance: not bound -!missing-selector! AXCustomContent::value not bound -!missing-type! AXCustomContent not bound diff --git a/tests/xtro-sharpie/macOS-Accessibility.todo b/tests/xtro-sharpie/macOS-Accessibility.todo deleted file mode 100644 index 81da6e6c90a4..000000000000 --- a/tests/xtro-sharpie/macOS-Accessibility.todo +++ /dev/null @@ -1,12 +0,0 @@ -!missing-enum! AXCustomContentImportance not bound -!missing-pinvoke! AXNameFromColor is not bound -!missing-protocol! AXCustomContentProvider not bound -!missing-selector! +AXCustomContent::customContentWithAttributedLabel:attributedValue: not bound -!missing-selector! +AXCustomContent::customContentWithLabel:value: not bound -!missing-selector! AXCustomContent::attributedLabel not bound -!missing-selector! AXCustomContent::attributedValue not bound -!missing-selector! AXCustomContent::importance not bound -!missing-selector! AXCustomContent::label not bound -!missing-selector! AXCustomContent::setImportance: not bound -!missing-selector! AXCustomContent::value not bound -!missing-type! AXCustomContent not bound diff --git a/tests/xtro-sharpie/tvOS-Accessibility.todo b/tests/xtro-sharpie/tvOS-Accessibility.todo deleted file mode 100644 index 81da6e6c90a4..000000000000 --- a/tests/xtro-sharpie/tvOS-Accessibility.todo +++ /dev/null @@ -1,12 +0,0 @@ -!missing-enum! AXCustomContentImportance not bound -!missing-pinvoke! AXNameFromColor is not bound -!missing-protocol! AXCustomContentProvider not bound -!missing-selector! +AXCustomContent::customContentWithAttributedLabel:attributedValue: not bound -!missing-selector! +AXCustomContent::customContentWithLabel:value: not bound -!missing-selector! AXCustomContent::attributedLabel not bound -!missing-selector! AXCustomContent::attributedValue not bound -!missing-selector! AXCustomContent::importance not bound -!missing-selector! AXCustomContent::label not bound -!missing-selector! AXCustomContent::setImportance: not bound -!missing-selector! AXCustomContent::value not bound -!missing-type! AXCustomContent not bound diff --git a/tests/xtro-sharpie/watchOS-Accessibility.todo b/tests/xtro-sharpie/watchOS-Accessibility.todo deleted file mode 100644 index 81da6e6c90a4..000000000000 --- a/tests/xtro-sharpie/watchOS-Accessibility.todo +++ /dev/null @@ -1,12 +0,0 @@ -!missing-enum! AXCustomContentImportance not bound -!missing-pinvoke! AXNameFromColor is not bound -!missing-protocol! AXCustomContentProvider not bound -!missing-selector! +AXCustomContent::customContentWithAttributedLabel:attributedValue: not bound -!missing-selector! +AXCustomContent::customContentWithLabel:value: not bound -!missing-selector! AXCustomContent::attributedLabel not bound -!missing-selector! AXCustomContent::attributedValue not bound -!missing-selector! AXCustomContent::importance not bound -!missing-selector! AXCustomContent::label not bound -!missing-selector! AXCustomContent::setImportance: not bound -!missing-selector! AXCustomContent::value not bound -!missing-type! AXCustomContent not bound diff --git a/tools/common/Frameworks.cs b/tools/common/Frameworks.cs index 7d96953add61..72cc2a33f15d 100644 --- a/tools/common/Frameworks.cs +++ b/tools/common/Frameworks.cs @@ -199,6 +199,7 @@ public static Frameworks MacFrameworks { { "CallKit", "CallKit", 10,16 }, { "ClassKit", "ClassKit", 10,16 }, { "ReplayKit", "ReplayKit", 10,16 }, + { "Accessibility", "Accessibility", 10,16 }, }; } return mac_frameworks; @@ -337,6 +338,7 @@ public static Frameworks GetiOSFrameworks (Application app) { "AppClip", "AppClip", 14,0 }, { "UniformTypeIdentifiers", "UniformTypeIdentifiers", 14,0 }, + { "Accessibility", "Accessibility", 14,0 }, // the above MUST be kept in sync with simlauncher // see tools/mtouch/Makefile @@ -404,6 +406,7 @@ public static Frameworks GetwatchOSFrameworks (Application app) { "StoreKit", "StoreKit", 6,2 }, { "UniformTypeIdentifiers", "UniformTypeIdentifiers", 7,0 }, + { "Accessibility", "Accessibility", 7,0 }, }; } return watch_frameworks; @@ -485,6 +488,7 @@ public static Frameworks TVOSFrameworks { { "LinkPresentation", "LinkPresentation", 14,0 }, { "UniformTypeIdentifiers", "UniformTypeIdentifiers", 14,0 }, + { "Accessibility", "Accessibility", 14,0 }, }; } return tvos_frameworks; diff --git a/tools/mtouch/Makefile b/tools/mtouch/Makefile index e6bb935d26aa..d15c1f78b729 100644 --- a/tools/mtouch/Makefile +++ b/tools/mtouch/Makefile @@ -162,6 +162,7 @@ SIMLAUNCHER_FRAMEWORKS = \ -weak_framework AutomaticAssessmentConfiguration \ \ -weak_framework AppClip \ + -weak_framework Accessibility \ # keep the above list of weak_framework # 1. grouped by iOS versions;