Skip to content

[Accessibility] Implement Xcode 16.0 beta 1-6 changes. #21070

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

Merged
merged 4 commits into from
Sep 5, 2024
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
17 changes: 17 additions & 0 deletions src/Accessibility/AXPrefers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,22 @@ public static bool HorizontalTextEnabled ()
return AXPrefersHorizontalTextLayout () != 0;
}

#if NET
[SupportedOSPlatform ("ios18.0")]
[SupportedOSPlatform ("maccatalyst18.0")]
[SupportedOSPlatform ("macos15.0")]
[SupportedOSPlatform ("tvos18.0")]
[DllImport (Constants.AccessibilityLibrary)]
static extern byte AXPrefersNonBlinkingTextInsertionIndicator ();

[SupportedOSPlatform ("ios18.0")]
[SupportedOSPlatform ("maccatalyst18.0")]
[SupportedOSPlatform ("macos15.0")]
[SupportedOSPlatform ("tvos18.0")]
public static bool NonBlinkingTextInsertionIndicator ()
{
return AXPrefersNonBlinkingTextInsertionIndicator () != 0;
}
#endif // NET
}
}
76 changes: 76 additions & 0 deletions src/Accessibility/AXSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#nullable enable

using System;
using System.Runtime.InteropServices;

using CoreGraphics;
using Foundation;
using ObjCRuntime;

#if NET

namespace Accessibility {

[SupportedOSPlatform ("ios18.0")]
[SupportedOSPlatform ("maccatalyst18.0")]
[SupportedOSPlatform ("macos15.0")]
[SupportedOSPlatform ("tvos18.0")]
[Native]
public enum AXSettingsFeature : long {
/// <summary>Jump to the "Allow Apps to Request to Use" setting in Personal Voice.</summary>
PersonalVoiceAllowAppsToRequestToUse = 1,
}

public static class AXSettings {
[SupportedOSPlatform ("ios18.0")]
[SupportedOSPlatform ("maccatalyst18.0")]
[SupportedOSPlatform ("macos15.0")]
[SupportedOSPlatform ("tvos18.0")]
[DllImport (Constants.AccessibilityLibrary)]
static extern byte AXAssistiveAccessEnabled ();

/// <summary>Returns whether Assistive Access is running.</summary>
[SupportedOSPlatform ("ios18.0")]
[SupportedOSPlatform ("maccatalyst18.0")]
[SupportedOSPlatform ("macos15.0")]
[SupportedOSPlatform ("tvos18.0")]
public static bool IsAssistiveAccessEnabled {
get {
return AXAssistiveAccessEnabled () != 0;
}
}

[SupportedOSPlatform ("ios18.0")]
[SupportedOSPlatform ("maccatalyst18.0")]
[SupportedOSPlatform ("macos15.0")]
[SupportedOSPlatform ("tvos18.0")]
[DllImport (Constants.AccessibilityLibrary)]
unsafe static extern void AXOpenSettingsFeature (nint /* AXSettingsFeature */ feature, BlockLiteral *block);

/// <summary>Open the Settings app to the specified section.</summary>
/// <param name="feature">The section to open.</param>
/// <param name="completionHandler">This callback is called when the section has been opened. The <see cref="Foundation.NSError" /> argument will be null if successful.</param>
[SupportedOSPlatform ("ios18.0")]
[SupportedOSPlatform ("maccatalyst18.0")]
[SupportedOSPlatform ("macos15.0")]
[SupportedOSPlatform ("tvos18.0")]
public unsafe static void OpenSettingsFeature (AXSettingsFeature feature, Action<NSError?> completionHandler)
{
delegate* unmanaged<IntPtr, IntPtr, void> trampoline = &OpenSettingsFeatureCompletionHandler;
using var block = new BlockLiteral (trampoline, completionHandler, typeof (AXSettings), nameof (OpenSettingsFeatureCompletionHandler));
AXOpenSettingsFeature ((nint) (long) feature, &block);
}

[UnmanagedCallersOnly]
static void OpenSettingsFeatureCompletionHandler (IntPtr block, IntPtr error)
{
var del = BlockLiteral.GetTarget<Action<NSError?>> (block);
if (del is not null) {
var errorObject = Runtime.GetNSObject<NSError> (error);
del (errorObject);
}
}
}
}

#endif // NET
44 changes: 44 additions & 0 deletions src/accessibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,50 @@ partial interface AXPrefers {
[Notification]
[Field ("AXPrefersHorizontalTextLayoutDidChangeNotification")]
NSString HorizontalTextLayoutDidChangeNotification { get; }

[Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)]
[Notification]
[Field ("AXPrefersNonBlinkingTextInsertionIndicatorDidChangeNotification")]
NSString NonBlinkingTextInsertionIndicatorDidChangeNotification { get; }
}

[Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface AXRequest : NSCopying, NSSecureCoding {
[Static]
[Export ("currentRequest"), NullAllowed]
AXRequest Current { get; }

[Export ("technology")]
[BindAs (typeof (AXTechnology))]
NSString Technology { get; }
}

[Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)]
enum AXTechnology {
[Field ("AXTechnologyVoiceOver")]
VoiceOver,

[Field ("AXTechnologySwitchControl")]
SwitchControl,

[Field ("AXTechnologyVoiceControl")]
VoiceControl,

[Field ("AXTechnologyFullKeyboardAccess")]
FullKeyboardAccess,

[Field ("AXTechnologySpeakScreen")]
SpeakScreen,

[Field ("AXTechnologyAutomation")]
Automation,

[Field ("AXTechnologyHoverText")]
HoverText,

[Field ("AXTechnologyZoom")]
Zoom,
}
}
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ ACCESSIBILITY_SOURCES = \
Accessibility/AXHearingUtilities.cs \
Accessibility/AXAnimatedImagesUtilities.cs \
Accessibility/AXPrefers.cs \
Accessibility/AXSettings.cs \

# Accounts

Expand Down
17 changes: 17 additions & 0 deletions tests/cecil-tests/Documentation.KnownFailures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,14 @@ F:Accessibility.AXHearingDeviceEar.Right
F:Accessibility.AXNumericDataAxisDescriptorScale.Linear
F:Accessibility.AXNumericDataAxisDescriptorScale.Ln
F:Accessibility.AXNumericDataAxisDescriptorScale.Log10
F:Accessibility.AXTechnology.Automation
F:Accessibility.AXTechnology.FullKeyboardAccess
F:Accessibility.AXTechnology.HoverText
F:Accessibility.AXTechnology.SpeakScreen
F:Accessibility.AXTechnology.SwitchControl
F:Accessibility.AXTechnology.VoiceControl
F:Accessibility.AXTechnology.VoiceOver
F:Accessibility.AXTechnology.Zoom
F:AccessorySetupKit.ASAccessoryEventType.AccessoryAdded
F:AccessorySetupKit.ASAccessoryEventType.AccessoryChanged
F:AccessorySetupKit.ASAccessoryEventType.AccessoryRemoved
Expand Down Expand Up @@ -21317,6 +21325,9 @@ M:Accessibility.AXNumericDataAxisDescriptor.#ctor(Foundation.NSAttributedString,
M:Accessibility.AXNumericDataAxisDescriptor.#ctor(System.String,System.Double,System.Double,Foundation.NSNumber[],System.Func{System.Double,Foundation.NSString})
M:Accessibility.AXNumericDataAxisDescriptor.Copy(Foundation.NSZone)
M:Accessibility.AXPrefers.HorizontalTextEnabled
M:Accessibility.AXPrefers.NonBlinkingTextInsertionIndicator
M:Accessibility.AXRequest.Copy(Foundation.NSZone)
M:Accessibility.AXRequest.EncodeTo(Foundation.NSCoder)
M:AccessorySetupKit.ASAccessorySession.Activate(CoreFoundation.DispatchQueue,System.Action{AccessorySetupKit.ASAccessoryEvent})
M:AccessorySetupKit.ASAccessorySession.FailAuthorization(AccessorySetupKit.ASAccessory,AccessorySetupKit.ASAccessorySessionCompletionHandler)
M:AccessorySetupKit.ASAccessorySession.FailAuthorizationAsync(AccessorySetupKit.ASAccessory)
Expand Down Expand Up @@ -52711,6 +52722,9 @@ P:Accessibility.AXNumericDataAxisDescriptor.Title
P:Accessibility.AXNumericDataAxisDescriptor.UpperBound
P:Accessibility.AXNumericDataAxisDescriptor.ValueDescriptionProvider
P:Accessibility.AXPrefers.HorizontalTextLayoutDidChangeNotification
P:Accessibility.AXPrefers.NonBlinkingTextInsertionIndicatorDidChangeNotification
P:Accessibility.AXRequest.Current
P:Accessibility.AXRequest.Technology
P:Accessibility.IAXBrailleMapRenderer.AccessibilityBrailleMapRenderer
P:Accessibility.IAXBrailleMapRenderer.AccessibilityBrailleMapRenderRegion
P:Accessibility.IAXChart.AccessibilityChartDescriptor
Expand Down Expand Up @@ -78208,6 +78222,9 @@ T:Accessibility.AXHearingDeviceEar
T:Accessibility.AXHearingUtilities
T:Accessibility.AXNumericDataAxisDescriptorScale
T:Accessibility.AXPrefers
T:Accessibility.AXSettings
T:Accessibility.AXSettingsFeature
T:Accessibility.AXTechnology
T:Accessibility.IAXBrailleMapRenderer
T:Accessibility.IAXChart
T:Accessibility.IAXCustomContentProvider
Expand Down
31 changes: 31 additions & 0 deletions tests/monotouch-test/Accessibility/AXPrefers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Copyright 2024 Microsoft Corp
//

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

namespace MonoTouchFixtures.Accessibility {

[TestFixture]
[Preserve (AllMembers = true)]
public class AXPrefersTests {
[Test]
public void HorizontalTextEnabled ()
{
TestRuntime.AssertXcodeVersion (15, 0);
Assert.That (AXPrefers.HorizontalTextEnabled, Is.EqualTo (true).Or.EqualTo (false), "HorizontalTextEnabled");
}

#if NET
[Test]
public void NonBlinkingTextInsertionIndicator ()
{
TestRuntime.AssertXcodeVersion (16, 0);
Assert.That (AXPrefers.NonBlinkingTextInsertionIndicator, Is.EqualTo (true).Or.EqualTo (false), "NonBlinkingTextInsertionIndicator");
}
#endif
}
}
48 changes: 48 additions & 0 deletions tests/monotouch-test/Accessibility/AXSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// Copyright 2024 Microsoft Corp
//

using System;
using System.Threading.Tasks;

using Accessibility;
using Foundation;

using NUnit.Framework;

namespace MonoTouchFixtures.Accessibility {

[TestFixture]
[Preserve (AllMembers = true)]
public class AXSettingsTest {
#if NET
[Test]
public void IsAssistiveAccessEnabled ()
{
TestRuntime.AssertXcodeVersion (16, 0);
Assert.That (AXSettings.IsAssistiveAccessEnabled, Is.EqualTo (true).Or.EqualTo (false), "IsAssistiveAccessEnabled");
}

static bool testedOnce;
[Test]
public void OpenSettingsFeature ()
{
TestRuntime.AssertXcodeVersion (16, 0);

if (!testedOnce) {
Assert.Ignore ("This test opens the Settings app (stopping executing of monotouch-test), so it's ignored when running automatically. Run again to actually run it (you'll have to switch back to monotouch-test manually).");
testedOnce = true;
}

NSError? error = null;
var didComplete = new TaskCompletionSource<bool> ();
AXSettings.OpenSettingsFeature (AXSettingsFeature.PersonalVoiceAllowAppsToRequestToUse, (e) => {
e = error;
didComplete.TrySetResult (true);
});
Assert.IsTrue (TestRuntime.RunAsync (TimeSpan.FromSeconds (30), didComplete.Task), "Timed out");
Assert.IsNull (error);
}
#endif
}
}

This file was deleted.

16 changes: 0 additions & 16 deletions tests/xtro-sharpie/api-annotations-dotnet/iOS-Accessibility.todo

This file was deleted.

16 changes: 0 additions & 16 deletions tests/xtro-sharpie/api-annotations-dotnet/macOS-Accessibility.todo

This file was deleted.

16 changes: 0 additions & 16 deletions tests/xtro-sharpie/api-annotations-dotnet/tvOS-Accessibility.todo

This file was deleted.

12 changes: 0 additions & 12 deletions tests/xtro-sharpie/iOS-Accessibility.todo
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
!missing-enum! AXSettingsFeature not bound
!missing-field! AXPrefersNonBlinkingTextInsertionIndicatorDidChangeNotification not bound
!missing-pinvoke! AXAssistiveAccessEnabled is not bound
!missing-pinvoke! AXOpenSettingsFeature is not bound
!missing-pinvoke! AXPrefersNonBlinkingTextInsertionIndicator is not bound
!missing-field! AXTechnologyAutomation not bound
!missing-field! AXTechnologyFullKeyboardAccess not bound
!missing-field! AXTechnologyHoverText not bound
!missing-field! AXTechnologySpeakScreen not bound
!missing-field! AXTechnologySwitchControl not bound
!missing-field! AXTechnologyVoiceControl not bound
!missing-field! AXTechnologyVoiceOver not bound
!missing-field! AXTechnologyZoom not bound
!missing-selector! +AXRequest::currentRequest not bound
!missing-selector! AXRequest::technology not bound
!missing-type! AXRequest not bound
12 changes: 0 additions & 12 deletions tests/xtro-sharpie/macOS-Accessibility.todo
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
!missing-enum! AXSettingsFeature not bound
!missing-field! AXPrefersNonBlinkingTextInsertionIndicatorDidChangeNotification not bound
!missing-pinvoke! AXAssistiveAccessEnabled is not bound
!missing-pinvoke! AXOpenSettingsFeature is not bound
!missing-pinvoke! AXPrefersNonBlinkingTextInsertionIndicator is not bound
!missing-field! AXTechnologyAutomation not bound
!missing-field! AXTechnologyFullKeyboardAccess not bound
!missing-field! AXTechnologyHoverText not bound
!missing-field! AXTechnologySpeakScreen not bound
!missing-field! AXTechnologySwitchControl not bound
!missing-field! AXTechnologyVoiceControl not bound
!missing-field! AXTechnologyVoiceOver not bound
!missing-field! AXTechnologyZoom not bound
!missing-selector! +AXRequest::currentRequest not bound
!missing-selector! AXRequest::technology not bound
!missing-type! AXRequest not bound
Loading