Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions apidoc/Titanium/UI/Android/Android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
9 changes: 9 additions & 0 deletions apidoc/Titanium/UI/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ description: |
* <Titanium.UI.View.accessibilityValue>
* <Titanium.UI.View.accessibilityHint>
* <Titanium.UI.View.accessibilityHidden>
* <Titanium.UI.View.accessibilityImportant>

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
Expand Down Expand Up @@ -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: |
Expand Down
Loading