Skip to content

Commit

Permalink
[Accessibility] Add new Framework from Xcode 12 beta 1. (#9086)
Browse files Browse the repository at this point in the history
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
  • Loading branch information
mandel-macaque and rolfbjarne authored Jul 15, 2020
1 parent 0bf816a commit 2b35db0
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 50 deletions.
1 change: 1 addition & 0 deletions src/Constants.iOS.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
5 changes: 3 additions & 2 deletions src/Constants.mac.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
1 change: 1 addition & 0 deletions src/Constants.tvos.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
1 change: 1 addition & 0 deletions src/Constants.watch.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
9 changes: 9 additions & 0 deletions src/CoreGraphics/CGColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
53 changes: 53 additions & 0 deletions src/accessibility.cs
Original file line number Diff line number Diff line change
@@ -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; }
}

}
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,7 @@ SHARED_SOURCES = \
#

COMMON_FRAMEWORKS = \
Accessibility \
Accelerate \
AuthenticationServices \
AVFoundation \
Expand Down
9 changes: 9 additions & 0 deletions tests/monotouch-test/CoreGraphics/ColorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

}
}

12 changes: 0 additions & 12 deletions tests/xtro-sharpie/iOS-Accessibility.todo

This file was deleted.

12 changes: 0 additions & 12 deletions tests/xtro-sharpie/macOS-Accessibility.todo

This file was deleted.

12 changes: 0 additions & 12 deletions tests/xtro-sharpie/tvOS-Accessibility.todo

This file was deleted.

12 changes: 0 additions & 12 deletions tests/xtro-sharpie/watchOS-Accessibility.todo

This file was deleted.

4 changes: 4 additions & 0 deletions tools/common/Frameworks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -485,6 +488,7 @@ public static Frameworks TVOSFrameworks {

{ "LinkPresentation", "LinkPresentation", 14,0 },
{ "UniformTypeIdentifiers", "UniformTypeIdentifiers", 14,0 },
{ "Accessibility", "Accessibility", 14,0 },
};
}
return tvos_frameworks;
Expand Down
1 change: 1 addition & 0 deletions tools/mtouch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

1 comment on commit 2b35db0

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build was (probably) aborted

🔥 Jenkins job (on internal Jenkins) failed in stage(s) 'Running XM tests on '10.16'' 🔥 : hudson.AbortException: script returned exit code 1

Build succeeded
✅ Packages:

API Diff (from stable)
ℹ️ API Diff (from PR only) (please review changes)
ℹ️ Generator Diff (please review changes)
🔥 Xamarin.Mac tests on 10.16 failed: script returned exit code 1 🔥
Test run succeeded

Please sign in to comment.