Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Accessibility] Update bindings for Xcode 13.0 beta 1 #11998

Merged
merged 2 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/Accessibility/AXHearingUtilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Copyright 2021 Microsoft Corp
//
// Authors:
// Rachel Kang (rachelkang@microsoft.com)
//

#nullable enable

#if !TVOS && !MONOMAC

using System;
using System.Runtime.InteropServices;
using CoreGraphics;
using Foundation;
using ObjCRuntime;

namespace Accessibility {

// accessibility.cs already provide the following attributes on the type
// [iOS (15,0), NoMac, NoTV, Watch (8,0), MacCatalyst (15,0)]
public static partial class AXHearingUtilities {

[DllImport (Constants.AccessibilityLibrary)]
static extern /* AXHearingDeviceEar */ nint AXMFiHearingDeviceStreamingEar ();

[DllImport (Constants.AccessibilityLibrary)]
static extern /* NSArray<NSUUID *> * */ IntPtr AXMFiHearingDevicePairedUUIDs ();

[DllImport (Constants.AccessibilityLibrary, EntryPoint = "AXSupportsBidirectionalAXMFiHearingDeviceStreaming")]
[return: MarshalAs (UnmanagedType.I1)]
public static extern bool SupportsBidirectionalStreaming ();

public static AXHearingDeviceEar GetMFiHearingDeviceStreamingEar ()
{
return (AXHearingDeviceEar) (long) AXMFiHearingDeviceStreamingEar ();
}

public static NSUuid[] GetMFiHearingDevicePairedUuids ()
{
return NSArray.ArrayFromHandle<NSUuid> (AXMFiHearingDevicePairedUUIDs ());
}
}
}
#endif
260 changes: 260 additions & 0 deletions src/accessibility.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,95 @@
using System;
using CoreGraphics;
using Foundation;
using ObjCRuntime;

namespace Accessibility {

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[BaseType (typeof(NSObject))]
[DisableDefaultCtor]
interface AXCategoricalDataAxisDescriptor : AXDataAxisDescriptor
{
[Export ("categoryOrder", ArgumentSemantic.Copy)]
string[] CategoryOrder { get; set; }

[Export ("initWithTitle:categoryOrder:")]
[DesignatedInitializer]
IntPtr Constructor (string title, string[] categoryOrder);

[Export ("initWithAttributedTitle:categoryOrder:")]
[DesignatedInitializer]
IntPtr Constructor (NSAttributedString attributedTitle, string[] categoryOrder);
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Protocol]
interface AXChart
{
[Abstract]
[NullAllowed, Export ("accessibilityChartDescriptor", ArgumentSemantic.Strong)]
AXChartDescriptor AccessibilityChartDescriptor { get; set; }
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Native]
public enum AXChartDescriptorContentDirection : long
{
LeftToRight = 0,
RightToLeft,
TopToBottom,
BottomToTop,
RadialClockwise,
RadialCounterClockwise,
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[BaseType (typeof(NSObject))]
rachelkang marked this conversation as resolved.
Show resolved Hide resolved
[DisableDefaultCtor]
interface AXChartDescriptor : NSCopying
{
[NullAllowed, Export ("title")]
string Title { get; set; }

[NullAllowed, Export ("attributedTitle", ArgumentSemantic.Copy)]
NSAttributedString AttributedTitle { get; set; }

[NullAllowed, Export ("summary")]
string Summary { get; set; }

[Export ("contentDirection", ArgumentSemantic.Assign)]
AXChartDescriptorContentDirection ContentDirection { get; set; }

[Export ("contentFrame", ArgumentSemantic.Assign)]
CGRect ContentFrame { get; set; }

[Export ("series", ArgumentSemantic.Copy)]
AXDataSeriesDescriptor[] Series { get; set; }

[Export ("xAxis", ArgumentSemantic.Strong)]
IAXDataAxisDescriptor XAxis { get; set; }

[NullAllowed, Export ("yAxis", ArgumentSemantic.Strong)]
AXNumericDataAxisDescriptor YAxis { get; set; }

[NullAllowed, Export ("additionalAxes", ArgumentSemantic.Copy)]
IAXDataAxisDescriptor[] AdditionalAxes { get; set; }

[Export ("initWithTitle:summary:xAxisDescriptor:yAxisDescriptor:series:")]
IntPtr Constructor ([NullAllowed] string title, [NullAllowed] string summary, IAXDataAxisDescriptor xAxis, [NullAllowed] AXNumericDataAxisDescriptor yAxis, AXDataSeriesDescriptor[] series);

[Export ("initWithAttributedTitle:summary:xAxisDescriptor:yAxisDescriptor:series:")]
IntPtr Constructor ([NullAllowed] NSAttributedString attributedTitle, [NullAllowed] string summary, IAXDataAxisDescriptor xAxis, AXNumericDataAxisDescriptor yAxis, AXDataSeriesDescriptor[] series);

[Export ("initWithTitle:summary:xAxisDescriptor:yAxisDescriptor:additionalAxes:series:")]
[DesignatedInitializer]
IntPtr Constructor ([NullAllowed] string title, [NullAllowed] string summary, IAXDataAxisDescriptor xAxis, [NullAllowed] AXNumericDataAxisDescriptor yAxis, [NullAllowed] IAXDataAxisDescriptor[] additionalAxes, AXDataSeriesDescriptor[] series);

[Export ("initWithAttributedTitle:summary:xAxisDescriptor:yAxisDescriptor:additionalAxes:series:")]
[DesignatedInitializer]
IntPtr Constructor ([NullAllowed] NSAttributedString attributedTitle, [NullAllowed] string summary, IAXDataAxisDescriptor xAxis, [NullAllowed] AXNumericDataAxisDescriptor yAxis, [NullAllowed] IAXDataAxisDescriptor[] additionalAxes, AXDataSeriesDescriptor[] series);
}

[Watch (7, 0), TV (14, 0), Mac (11, 0), iOS (14, 0)]
[MacCatalyst (14,0)]
[Native]
Expand Down Expand Up @@ -53,4 +139,178 @@ interface AXCustomContentProvider
AXCustomContent[] AccessibilityCustomContent { get; set; }
}

interface IAXDataAxisDescriptor {}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Protocol]
interface AXDataAxisDescriptor : NSCopying
{
[Abstract]
[Export ("title")]
string Title { get; set; }

[Abstract]
[Export ("attributedTitle", ArgumentSemantic.Copy)]
NSAttributedString AttributedTitle { get; set; }
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[BaseType (typeof(NSObject))]
rachelkang marked this conversation as resolved.
Show resolved Hide resolved
[DisableDefaultCtor]
interface AXDataPoint : NSCopying
{
[Export ("xValue", ArgumentSemantic.Copy)]
AXDataPointValue XValue { get; set; }

[NullAllowed, Export ("yValue", ArgumentSemantic.Copy)]
AXDataPointValue YValue { get; set; }

[Export ("additionalValues", ArgumentSemantic.Copy)]
AXDataPointValue[] AdditionalValues { get; set; }

[NullAllowed, Export ("label")]
string Label { get; set; }

[NullAllowed, Export ("attributedLabel", ArgumentSemantic.Copy)]
NSAttributedString AttributedLabel { get; set; }

[Export ("initWithX:y:")]
IntPtr Constructor (AXDataPointValue xValue, [NullAllowed] AXDataPointValue yValue);

[Export ("initWithX:y:additionalValues:")]
IntPtr Constructor (AXDataPointValue xValue, [NullAllowed] AXDataPointValue yValue, [NullAllowed] AXDataPointValue[] additionalValues);

[Export ("initWithX:y:additionalValues:label:")]
[DesignatedInitializer]
IntPtr Constructor (AXDataPointValue xValue, [NullAllowed] AXDataPointValue yValue, [NullAllowed] AXDataPointValue[] additionalValues, [NullAllowed] string label);
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[BaseType (typeof(NSObject))]
rachelkang marked this conversation as resolved.
Show resolved Hide resolved
[DisableDefaultCtor]
interface AXDataPointValue : NSCopying
{
[Export ("number", ArgumentSemantic.Assign)]
double Number { get; set; }

[Export ("category")]
string Category { get; set; }

[Static]
[Export ("valueWithNumber:")]
AXDataPointValue CreateValueWithNumber (double number);

[Static]
[Export ("valueWithCategory:")]
AXDataPointValue CreateValueWithCategory (string category);
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[BaseType (typeof(NSObject))]
rachelkang marked this conversation as resolved.
Show resolved Hide resolved
[DisableDefaultCtor]
interface AXDataSeriesDescriptor : NSCopying
{
[NullAllowed, Export ("name")]
string Name { get; set; }

[Export ("attributedName", ArgumentSemantic.Copy)]
NSAttributedString AttributedName { get; set; }

[Export ("isContinuous")]
bool IsContinuous { get; set; }

[Export ("dataPoints", ArgumentSemantic.Copy)]
AXDataPoint[] DataPoints { get; set; }

[Export ("initWithName:isContinuous:dataPoints:")]
[DesignatedInitializer]
IntPtr Constructor (string name, bool isContinuous, AXDataPoint[] dataPoints);

[Export ("initWithAttributedName:isContinuous:dataPoints:")]
[DesignatedInitializer]
IntPtr Constructor (NSAttributedString attributedName, bool isContinuous, AXDataPoint[] dataPoints);
}

[Watch (8,0), NoTV, NoMac, iOS (15,0), MacCatalyst (15,0)]
[Flags]
[Native]
public enum AXHearingDeviceEar : ulong
{
None = 0,
Left = 1 << 1,
Right = 1 << 2,
Both = Left | Right,
}

[Watch (8,0), NoTV, NoMac, iOS (15,0), MacCatalyst (15,0)]
[Static]
[Partial]
partial interface AXHearingUtilities
{
[Field ("AXMFiHearingDeviceStreamingEarDidChangeNotification")]
rachelkang marked this conversation as resolved.
Show resolved Hide resolved
[Notification]
NSString StreamingEarDidChangeNotification { get; }

[Field ("AXMFiHearingDevicePairedUUIDsDidChangeNotification")]
rachelkang marked this conversation as resolved.
Show resolved Hide resolved
[Notification]
NSString PairedUUIDsDidChangeNotification { get; }
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[BaseType (typeof(NSObject))]
Copy link
Contributor

Choose a reason for hiding this comment

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

since it's only static members you should add [DisableDefaultCtor] since creating an instance of this type is not helpful (and can be confusing)

Copy link
Member

Choose a reason for hiding this comment

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

Do we need BaseType?

[DisableDefaultCtor]
interface AXLiveAudioGraph
{
[Static]
[Export ("start")]
void Start ();

[Static]
[Export ("updateValue:")]
void Update (double value);

[Static]
[Export ("stop")]
void Stop ();
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Native]
public enum AXNumericDataAxisDescriptorScale : long
{
Linear = 0,
Log10,
Ln,
}

delegate NSString ValueDescriptionProviderHandler (double dataValue);

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[BaseType (typeof(NSObject))]
[DisableDefaultCtor]
interface AXNumericDataAxisDescriptor : AXDataAxisDescriptor
{
[Export ("scaleType", ArgumentSemantic.Assign)]
AXNumericDataAxisDescriptorScale ScaleType { get; set; }

[Export ("lowerBound")]
double LowerBound { get; set; }

[Export ("upperBound")]
double UpperBound { get; set; }

[Export ("valueDescriptionProvider", ArgumentSemantic.Copy)]
ValueDescriptionProviderHandler ValueDescriptionProvider { get; set; }

[Export ("gridlinePositions", ArgumentSemantic.Copy)]
NSNumber[] GridlinePositions { get; set; }

[Export ("initWithTitle:lowerBound:upperBound:gridlinePositions:valueDescriptionProvider:")]
[DesignatedInitializer]
IntPtr Constructor (string title, double lowerBound, double upperBound, [NullAllowed] NSNumber[] gridlinePositions, Func<double, NSString> valueDescriptionProvider);

[Export ("initWithAttributedTitle:lowerBound:upperBound:gridlinePositions:valueDescriptionProvider:")]
[DesignatedInitializer]
IntPtr Constructor (NSAttributedString attributedTitle, double lowerBound, double upperBound, [NullAllowed] NSNumber[] gridlinePositions, Func<double, NSString> valueDescriptionProvider);
}
}
5 changes: 5 additions & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
ACCELERATE_SOURCES = \
Accelerate/vImageTypes.cs \

# Accessibility

ACCESSIBILITY_SOURCES = \
Accessibility/AXHearingUtilities.cs \

# Accounts

ACCOUNTS_API_SOURCES = \
Expand Down
47 changes: 47 additions & 0 deletions tests/monotouch-test/Accessibility/AXHearingUtilitiesTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// Copyright 2021 Microsoft Corp
//
// Authors:
// Rachel Kang (rachelkang@microsoft.com)
//

#if !__TVOS__ && !MONOMAC

using System;
using Foundation;
using Accessibility;
using NUnit.Framework;

namespace MonoTouchFixtures.Accessibility {

[TestFixture]
[Preserve (AllMembers = true)]
public class AXHearingUtilitiesTests {

[SetUp]
public void Setup ()
{
TestRuntime.AssertXcodeVersion (13, 0);
}

[Test]
public void GetHearingDeviceEar ()
{
Assert.That (AXHearingUtilities.GetMFiHearingDeviceStreamingEar (), Is.EqualTo (AXHearingDeviceEar.None), "default");
}

[Test]
public void GetDoesSupportBidirectionalHearing ()
{
Assert.That (AXHearingUtilities.SupportsBidirectionalStreaming (), Is.EqualTo (false), "GetDoesSupportBidirectionalHearing");
}

[Test]
public void GetHearingDevicePairedUuids ()
{
NSUuid[] emptyArray = new NSUuid[0];
Assert.That (AXHearingUtilities.GetMFiHearingDevicePairedUuids (), Is.EqualTo (emptyArray), "GetHearingDevicePairedUuids");
}
}
}
#endif
Loading