Skip to content
1 change: 1 addition & 0 deletions Ports/iOSPort/nativeSources/CodenameOne_GLViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -4018,6 +4018,7 @@ - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)co




- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
{
}
Expand Down
10 changes: 10 additions & 0 deletions Ports/iOSPort/nativeSources/IOSNative.m
Original file line number Diff line number Diff line change
Expand Up @@ -10315,3 +10315,13 @@ JAVA_BOOLEAN com_codename1_impl_ios_IOSNative_isRTLString___java_lang_String_R_b
POOL_END();
return NO;
}

void com_codename1_impl_ios_IOSNative_announceForAccessibility___java_lang_String(CN1_THREAD_STATE_MULTI_ARG JAVA_OBJECT text) {
if (text == JAVA_NULL) {
return;
}
POOL_BEGIN();
NSString *nsText = toNSString(CN1_THREAD_STATE_PASS_ARG text);
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, nsText);
POOL_END();
}
Original file line number Diff line number Diff line change
Expand Up @@ -9494,6 +9494,11 @@ public boolean isJailbrokenDevice() {
Boolean b = canExecute("cydia://package/com.example.package");
return b != null && b.booleanValue();
}

@Override
public void announceForAccessibility(final Component cmp, final String text) {
IOSNative.announceForAccessibility(text);
}
}


Expand Down
2 changes: 2 additions & 0 deletions Ports/iOSPort/src/com/codename1/impl/ios/IOSNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -721,5 +721,7 @@ native void nativeSetTransformMutable(
native int getDisplaySafeInsetBottom();

native boolean isRTLString(String javaString);

public static native void announceForAccessibility(String text);

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.codenameone.examples.hellocodenameone.tests.graphics.TransformPerspective;
import com.codenameone.examples.hellocodenameone.tests.graphics.TransformRotation;
import com.codenameone.examples.hellocodenameone.tests.graphics.TransformTranslation;
import com.codenameone.examples.hellocodenameone.tests.accessibility.AccessibilityTest;

public final class Cn1ssDeviceRunner extends DeviceRunner {
private static final BaseTest[] TEST_CLASSES = new BaseTest[] {
Expand Down Expand Up @@ -63,7 +64,8 @@ public final class Cn1ssDeviceRunner extends DeviceRunner {
new TransformCamera(),
new BrowserComponentScreenshotTest(),
new MediaPlaybackScreenshotTest(),
new InPlaceEditViewTest()
new InPlaceEditViewTest(),
new AccessibilityTest()
};

public void runSuite() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.codenameone.examples.hellocodenameone.tests.accessibility;

import com.codename1.ui.Display;
import com.codenameone.examples.hellocodenameone.tests.BaseTest;

public class AccessibilityTest extends BaseTest {
@Override
public boolean runTest() throws Exception {
com.codename1.ui.CN.callSerially(() -> {
String expected = "Testing accessibility announcement";
// Just verify that invoking this doesn't crash the app
Display.getInstance().announceForAccessibility(expected);
done();
});
return true;
}

@Override
public boolean shouldTakeScreenshot() {
return false;
}
}
Loading