Skip to content

Commit

Permalink
fix(android): accessibility properties for ListItem
Browse files Browse the repository at this point in the history
- Remove hardcoded content description.
- Add a11y properties to the refresh list.
Need to refresh all a11y properties if any of them are changed, because native "contentDescription"
property is build as their concatenation.

refs TIMOB-24415
  • Loading branch information
drauggres committed Jun 3, 2019
1 parent 78c62cc commit 65f4020
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion android/modules/ui/res/layout/titanium_ui_list_item.xml
Expand Up @@ -25,7 +25,6 @@
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:layout_gravity="right"
android:contentDescription="One of the following images: checkmark, child, or disclosure"
android:focusable="false"
android:focusableInTouchMode="false"
android:maxHeight="17dp"
Expand Down
Expand Up @@ -90,12 +90,12 @@ public class TiListView extends TiUIView implements OnSearchChangeListener
* However, since Android randomly selects a cached view to recycle, our cached properties
* will not be in sync with the native view's properties when user changes those values via
* User Interaction - i.e click. For this reason, we create a list that contains the properties
* that must be reset every time a view is recycled, to ensure synchronization. Currently, only
* "value" is in this list to correctly update the value of Ti.UI.Switch.
* that must be reset every time a view is recycled, to ensure synchronization.
*/
public static List<String> MUST_SET_PROPERTIES =
Arrays.asList(TiC.PROPERTY_VALUE, TiC.PROPERTY_AUTO_LINK, TiC.PROPERTY_TEXT, TiC.PROPERTY_HTML,
TiC.PROPERTY_WIDTH, TiC.PROPERTY_HEIGHT, TiC.PROPERTY_IMAGE);
Arrays.asList(TiC.PROPERTY_ACCESSIBILITY_HINT, TiC.PROPERTY_ACCESSIBILITY_LABEL,
TiC.PROPERTY_ACCESSIBILITY_VALUE, TiC.PROPERTY_AUTO_LINK, TiC.PROPERTY_HEIGHT, TiC.PROPERTY_HTML,
TiC.PROPERTY_IMAGE, TiC.PROPERTY_TEXT, TiC.PROPERTY_VALUE, TiC.PROPERTY_WIDTH);

public static final String MIN_SEARCH_HEIGHT = "50dp";
public static final int HEADER_FOOTER_WRAP_ID = View.generateViewId();
Expand Down
Expand Up @@ -338,7 +338,7 @@ protected void setNativeView(View view)
doSetClickable(nativeView, clickable);
nativeView.setOnFocusChangeListener(this);

applyAccessibilityProperties();
applyAccessibilityProperties(proxy.getProperties());
}

protected void setLayoutParams(LayoutParams layoutParams)
Expand Down Expand Up @@ -924,7 +924,7 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
}

} else if (key.indexOf("accessibility") == 0 && !key.equals(TiC.PROPERTY_ACCESSIBILITY_HIDDEN)) {
applyContentDescription();
applyContentDescription(proxy.getProperties());

} else if (key.equals(TiC.PROPERTY_ACCESSIBILITY_HIDDEN)) {
applyAccessibilityHidden(newValue);
Expand Down Expand Up @@ -1076,7 +1076,7 @@ public void processProperties(KrollDict d)

if (d.containsKey(TiC.PROPERTY_ACCESSIBILITY_HINT) || d.containsKey(TiC.PROPERTY_ACCESSIBILITY_LABEL)
|| d.containsKey(TiC.PROPERTY_ACCESSIBILITY_VALUE) || d.containsKey(TiC.PROPERTY_ACCESSIBILITY_HIDDEN)) {
applyAccessibilityProperties();
applyAccessibilityProperties(d);
}

if (d.containsKey(TiC.PROPERTY_ELEVATION) && !nativeViewNull) {
Expand Down Expand Up @@ -2144,12 +2144,12 @@ private void resetPostAnimationValues()
animatedAlpha = Float.MIN_VALUE; // we use min val to signal no val.
}

private void applyContentDescription()
private void applyContentDescription(KrollDict d)
{
if (proxy == null || nativeView == null) {
return;
}
String contentDescription = composeContentDescription();
String contentDescription = composeContentDescription(d);
if (contentDescription != null) {
nativeView.setContentDescription(contentDescription);
}
Expand Down Expand Up @@ -2214,10 +2214,10 @@ public static String composeContentDescription(KrollDict properties)
return buffer.toString();
}

private void applyAccessibilityProperties()
private void applyAccessibilityProperties(KrollDict d)
{
if (nativeView != null) {
applyContentDescription();
applyContentDescription(d);
applyAccessibilityHidden();
}
}
Expand Down

0 comments on commit 65f4020

Please sign in to comment.