Skip to content

Commit

Permalink
[Accessibility] Update bindings for Xcode 13.0 beta 1
Browse files Browse the repository at this point in the history
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Rachel Kang <rachelkang@microsoft.com>
  • Loading branch information
3 people committed Jun 30, 2021
1 parent 801063d commit eca53e5
Show file tree
Hide file tree
Showing 9 changed files with 357 additions and 423 deletions.
45 changes: 45 additions & 0 deletions src/Accessibility/AXHearingUtilities.cs
@@ -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
@@ -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))]
[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))]
[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))]
[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))]
[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")]
[Notification]
NSString StreamingEarDidChangeNotification { get; }

[Field ("AXMFiHearingDevicePairedUUIDsDidChangeNotification")]
[Notification]
NSString PairedUUIDsDidChangeNotification { get; }
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[BaseType (typeof(NSObject))]
[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
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
@@ -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

0 comments on commit eca53e5

Please sign in to comment.