diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/android/AndroidModule.java b/android/modules/ui/src/java/ti/modules/titanium/ui/android/AndroidModule.java index b6d6db771df..77bda19bd56 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/android/AndroidModule.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/android/AndroidModule.java @@ -32,6 +32,7 @@ import androidx.annotation.ColorInt; import androidx.core.content.ContextCompat; import androidx.core.view.GravityCompat; +import androidx.core.view.ViewCompat; import com.google.android.material.color.MaterialColors; @@ -262,6 +263,15 @@ public class AndroidModule extends KrollModule @Kroll.constant public static final int WEBVIEW_SCROLLBARS_HIDE_ALL = 3; + @Kroll.constant + public static final int IMPORTANT_FOR_ACCESSIBILITY_YES = ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES; + @Kroll.constant + public static final int IMPORTANT_FOR_ACCESSIBILITY_NO = ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO; + @Kroll.constant + public static final int IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS + = ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS; + @Kroll.constant + public static final int IMPORTANT_FOR_ACCESSIBILITY_AUTO = ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO; public AndroidModule() { super(); diff --git a/android/titanium/src/java/org/appcelerator/titanium/TiC.java b/android/titanium/src/java/org/appcelerator/titanium/TiC.java index 7cd2b42be22..ec8e59447ca 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/TiC.java +++ b/android/titanium/src/java/org/appcelerator/titanium/TiC.java @@ -233,6 +233,7 @@ public class TiC public static final String PROPERTY_ACCESSIBILITY_HINT = "accessibilityHint"; public static final String PROPERTY_ACCESSIBILITY_LABEL = "accessibilityLabel"; public static final String PROPERTY_ACCESSIBILITY_VALUE = "accessibilityValue"; + public static final String PROPERTY_ACCESSIBILITY_IMPORTANT = "accessibilityImportant"; public static final String PROPERTY_ACCESSIBILITY_DISABLE_LONG = "accessibilityDisableLongPress"; public static final String PROPERTY_ACCESSORY_TYPE = "accessoryType"; public static final String PROPERTY_ACTION = "action"; diff --git a/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java b/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java index 3d82f0448a9..c65d38ca78b 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java +++ b/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java @@ -71,6 +71,7 @@ TiC.PROPERTY_ACCESSIBILITY_LABEL, TiC.PROPERTY_ACCESSIBILITY_VALUE, TiC.PROPERTY_ACCESSIBILITY_HIDDEN, + TiC.PROPERTY_ACCESSIBILITY_IMPORTANT, // others TiC.PROPERTY_FOCUSABLE, TiC.PROPERTY_TOUCH_ENABLED, diff --git a/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java b/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java index 4715790ec6e..ebf053980d5 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java +++ b/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java @@ -905,12 +905,15 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP nativeView.setKeepScreenOn(TiConvert.toBoolean(newValue)); } - } else if (key.indexOf("accessibility") == 0 && !key.equals(TiC.PROPERTY_ACCESSIBILITY_HIDDEN)) { + } else if (key.indexOf("accessibility") == 0 && !key.equals(TiC.PROPERTY_ACCESSIBILITY_HIDDEN) + && !key.equals(TiC.PROPERTY_ACCESSIBILITY_IMPORTANT)) { applyContentDescription(); } else if (key.equals(TiC.PROPERTY_ACCESSIBILITY_HIDDEN)) { applyAccessibilityHidden(newValue); + } else if (key.equals(TiC.PROPERTY_ACCESSIBILITY_IMPORTANT)) { + applyAccessibilityImportant(newValue); } else if (key.equals(TiC.PROPERTY_ELEVATION)) { if (getOuterView() != null) { ViewCompat.setElevation(getOuterView(), TiConvert.toFloat(newValue)); @@ -1077,6 +1080,10 @@ public void processProperties(KrollDict d) applyContentDescription(d); } + if (d.containsKey(TiC.PROPERTY_ACCESSIBILITY_IMPORTANT)) { + applyAccessibilityImportant(d.get(TiC.PROPERTY_ACCESSIBILITY_IMPORTANT)); + } + if (d.containsKey(TiC.PROPERTY_ACCESSIBILITY_HIDDEN)) { applyAccessibilityHidden(d.get(TiC.PROPERTY_ACCESSIBILITY_HIDDEN)); } @@ -2328,6 +2335,16 @@ private void applyAccessibilityHidden(Object hiddenPropertyValue) ViewCompat.setImportantForAccessibility(nativeView, importanceMode); } + private void applyAccessibilityImportant(Object hiddenPropertyValue) + { + if (nativeView == null) { + return; + } + + int importanceMode = TiConvert.toInt(hiddenPropertyValue, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO); + ViewCompat.setImportantForAccessibility(nativeView, importanceMode); + } + /** * Our view proxy supports three properties to match iOS regarding * the text that is read aloud (or otherwise communicated) by the diff --git a/apidoc/Titanium/UI/Android/Android.yml b/apidoc/Titanium/UI/Android/Android.yml index cdd06fcb847..0bda312747a 100644 --- a/apidoc/Titanium/UI/Android/Android.yml +++ b/apidoc/Titanium/UI/Android/Android.yml @@ -74,6 +74,26 @@ methods: since: "9.1.0" properties: + - name: IMPORTANT_FOR_ACCESSIBILITY_YES + summary: The view is important for accessibility + type: Number + permission: read-only + + - name: IMPORTANT_FOR_ACCESSIBILITY_NO + summary: The view is not important for autofill, but its children (if any) will be traversed. + type: Number + permission: read-only + + - name: IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS + summary: The view is not important for accessibility, nor are any of its descendant views. + type: Number + permission: read-only + + - name: IMPORTANT_FOR_ACCESSIBILITY_AUTO + summary: Automatically determine whether a view is important for autofill. + type: Number + permission: read-only + - name: FLAG_LAYOUT_NO_LIMITS summary: Flag allowing window to extend into the status bar and navigation bar. description: | diff --git a/apidoc/Titanium/UI/View.yml b/apidoc/Titanium/UI/View.yml index 478e44fb812..949d12fb487 100644 --- a/apidoc/Titanium/UI/View.yml +++ b/apidoc/Titanium/UI/View.yml @@ -148,6 +148,7 @@ description: | * * * + * The first three, `accessibilityLabel`, `accessibilityValue` and `accessibilityHint`, are for setting text that will be relayed to the user by the assistive service (such as TalkBack on Android or VoiceOver @@ -1129,6 +1130,14 @@ properties: type: Boolean default: false + - name: accessibilityImportant + summary: Sets the accessibility important mode. + since: "13.2.0" + platforms: [android] + type: Number + constants: Titanium.UI.Android.IMPORTANT_* + default: null + - name: accessibilityHint summary: Briefly describes what performing an action (such as a click) on the view will do. description: |