Skip to content
Open
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
81 changes: 81 additions & 0 deletions CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
import com.codename1.ui.TextArea;
import com.codename1.ui.TextSelection;
import com.codename1.ui.Transform;
import com.codename1.ui.accessibility.AccessibilityManager;
import com.codename1.ui.accessibility.AccessibilityTreeSnapshot;
import com.codename1.ui.animations.Animation;
import com.codename1.ui.animations.Transition;
import com.codename1.ui.events.ActionEvent;
Expand Down Expand Up @@ -11132,6 +11134,35 @@ public void announceForAccessibility(Component cmp, String text) {
// should override this method.
}

/// Called after the portable semantic tree changes. Platform ports should
/// invalidate their native virtual accessibility roots and request the latest
/// immutable snapshot with {@link #getAccessibilityTreeSnapshot()}.
public void accessibilityTreeChanged(int changeType) {
}

/// Returns the latest immutable semantic tree for the current form.
public AccessibilityTreeSnapshot getAccessibilityTreeSnapshot() {
return AccessibilityManager.getInstance().getCurrentSnapshot();
}

/// Dispatches an action from a native virtual accessibility node onto the EDT.
public boolean performAccessibilityAction(long nodeId, String actionId, Object argument) {
return AccessibilityManager.getInstance().performAction(nodeId, actionId, argument);
}

/// Returns true when this port exposes the portable virtual semantic tree.
public boolean isAccessibilityTreeSupported() {
return false;
}

/// Returns true when semantic invalidations should be projected eagerly.
/// Pull-based ports should override this to return true only while assistive
/// technology is active. Ports whose semantic projection must always remain
/// attached, such as web ARIA, may return true unconditionally.
public boolean isAccessibilityTreeUpdateRequired() {
return isAccessibilityTreeSupported();
}

/// Returns true if the user has selected larger type fonts in the system settings.
/// Default implementation returns false.
///
Expand All @@ -11154,6 +11185,56 @@ public float getLargerTextScale() {
return 1.0f;
}

/// Returns true when the user requests stronger foreground/background contrast.
public boolean isHighContrastEnabled() {
return false;
}

/// Returns true when the user requests that information isn't conveyed by color alone.
public boolean isDifferentiateWithoutColorEnabled() {
return false;
}

/// Returns the selected color-vision correction mode.
public com.codename1.ui.AccessibilityColorVisionDeficiency getColorVisionDeficiency() {
return com.codename1.ui.AccessibilityColorVisionDeficiency.UNKNOWN;
}

/// Returns true when the user requests reduced or disabled nonessential motion.
public boolean isReduceMotionEnabled() {
return false;
}

/// Returns true when the user requests reduced transparency and blur effects.
public boolean isReduceTransparencyEnabled() {
return false;
}

/// Returns true when the user requests heavier text weight.
public boolean isBoldTextEnabled() {
return false;
}

/// Returns true when the operating system is inverting displayed colors.
public boolean isInvertColorsEnabled() {
return false;
}

/// Returns true when the operating system requests a grayscale presentation.
public boolean isGrayscaleEnabled() {
return false;
}

/// Returns true when switches should include visible on/off labels.
public boolean isOnOffSwitchLabelsEnabled() {
return false;
}

/// Returns true when a screen reader or touch-exploration service is active.
public boolean isScreenReaderEnabled() {
return false;
}

/// Returns the stack trace from the exception on the given
/// thread. This API isn't supported on all platforms and may
/// return a blank string when unavailable.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2026, Codename One and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Codename One designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Codename One through http://www.codenameone.com/ if you
* need additional information or have any questions.
*/
package com.codename1.ui;

/// Describes a color-vision deficiency selected in the operating system or
/// simulated by the Java SE simulator.
///
/// Applications should never infer that color alone is safe when this value is
/// {@link #NONE} or {@link #UNKNOWN}. Use text, shape, iconography, or patterns
/// in addition to color for every important distinction.
public enum AccessibilityColorVisionDeficiency {
/// The platform reports that no color-vision correction is enabled.
NONE,
/// Reduced sensitivity to red light.
PROTANOPIA,
/// Reduced sensitivity to green light.
DEUTERANOPIA,
/// Reduced sensitivity to blue light.
TRITANOPIA,
/// Colors are presented as shades of gray.
MONOCHROMACY,
/// The platform doesn't expose the selected correction mode.
UNKNOWN
}
5 changes: 5 additions & 0 deletions CodenameOne/src/com/codename1/ui/Button.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package com.codename1.ui;

import com.codename1.ui.accessibility.AccessibilityManager;
import com.codename1.ui.events.ActionEvent;
import com.codename1.ui.events.ActionListener;
import com.codename1.ui.events.ActionSource;
Expand Down Expand Up @@ -992,7 +993,11 @@ public boolean isToggle() {
///
/// - `toggle`: the toggle to set
public void setToggle(boolean toggle) {
if (this.toggle == toggle) {
return;
}
this.toggle = toggle;
accessibilityChanged(AccessibilityManager.CHANGE_STRUCTURE | AccessibilityManager.CHANGE_STATE);
if (toggle && "CheckBox".equals(getUIID()) || "RadioButton".equals(getUIID())) {
setUIID("ToggleButton");
}
Expand Down
50 changes: 50 additions & 0 deletions CodenameOne/src/com/codename1/ui/CN.java
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,56 @@ public static Boolean isDarkMode() {
return Display.INSTANCE.isDarkMode();
}

/// Returns true when the user requests stronger foreground/background contrast.
public static boolean isHighContrastEnabled() {
return Display.INSTANCE.isHighContrastEnabled();
}

/// Returns true when the user requests that information isn't conveyed by color alone.
public static boolean isDifferentiateWithoutColorEnabled() {
return Display.INSTANCE.isDifferentiateWithoutColorEnabled();
}

/// Returns the selected color-vision correction mode.
public static AccessibilityColorVisionDeficiency getColorVisionDeficiency() {
return Display.INSTANCE.getColorVisionDeficiency();
}

/// Returns true when the user requests reduced or disabled nonessential motion.
public static boolean isReduceMotionEnabled() {
return Display.INSTANCE.isReduceMotionEnabled();
}

/// Returns true when the user requests reduced transparency and blur effects.
public static boolean isReduceTransparencyEnabled() {
return Display.INSTANCE.isReduceTransparencyEnabled();
}

/// Returns true when the user requests heavier text weight.
public static boolean isBoldTextEnabled() {
return Display.INSTANCE.isBoldTextEnabled();
}

/// Returns true when the operating system is inverting displayed colors.
public static boolean isInvertColorsEnabled() {
return Display.INSTANCE.isInvertColorsEnabled();
}

/// Returns true when the operating system requests a grayscale presentation.
public static boolean isGrayscaleEnabled() {
return Display.INSTANCE.isGrayscaleEnabled();
}

/// Returns true when switches should include visible on/off labels.
public static boolean isOnOffSwitchLabelsEnabled() {
return Display.INSTANCE.isOnOffSwitchLabelsEnabled();
}

/// Returns true when a screen reader or touch-exploration service is active.
public static boolean isScreenReaderEnabled() {
return Display.INSTANCE.isScreenReaderEnabled();
}

/// Override the default dark mode setting
///
/// #### Parameters
Expand Down
2 changes: 2 additions & 0 deletions CodenameOne/src/com/codename1/ui/CheckBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package com.codename1.ui;

import com.codename1.ui.accessibility.AccessibilityManager;
import com.codename1.cloud.BindTarget;
import com.codename1.ui.events.ActionEvent;
import com.codename1.ui.events.ActionListener;
Expand Down Expand Up @@ -173,6 +174,7 @@ public void setSelected(boolean selected) {
this.selected = selected;
if (changed) {
fireChangeEvent();
accessibilityChanged(AccessibilityManager.CHANGE_STATE);
}
repaint();
}
Expand Down
Loading
Loading