Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIMOB-11463 Android: Fix accessibility properties on old-style table rows. #3242

Merged
merged 1 commit into from
Oct 17, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public TiBaseTableViewItem(Activity activity)
if (Build.VERSION.SDK_INT >= 9 && density == DisplayMetrics.DENSITY_XHIGH) {
path = "/org/appcelerator/titanium/res/drawable/btn_check_buttonless_on_64.png";
}
checkIndicatorBitmap = BitmapFactory.decodeStream(KrollDict.class.getResourceAsStream(path));
checkIndicatorBitmap = BitmapFactory.decodeStream(KrollDict.class.getResourceAsStream(path));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.TiContext;
import org.appcelerator.titanium.TiDimension;
Expand All @@ -28,14 +29,20 @@
import android.app.Activity;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Handler;
import android.support.v4.view.ViewCompat;
import android.view.View;
import android.widget.ImageView;

public class TiTableViewRowProxyItem extends TiBaseTableViewItem
{
private static final String TAG = "TitaniumTableViewItem";

// Only check this once, since we potentially use this information
// every time we add a row. No sense checking it each time.
private static boolean ICS_OR_GREATER = (Build.VERSION.SDK_INT >= TiC.API_LEVEL_ICE_CREAM_SANDWICH);

private static final int LEFT_MARGIN = 5;
private static final int RIGHT_MARGIN = 7;

Expand All @@ -44,7 +51,6 @@ public class TiTableViewRowProxyItem extends TiBaseTableViewItem
private ImageView rightImage;
private TiCompositeLayout content;
private ArrayList<TiUIView> views;
// private boolean hasControls;
private TiDimension height = null;
private Item item;
private Object selectorSource;
Expand Down Expand Up @@ -178,7 +184,13 @@ protected void refreshOldStyleRow()
{
TableViewRowProxy rp = getRowProxy();
if (!rp.hasProperty(TiC.PROPERTY_TOUCH_ENABLED)) {
rp.setProperty(TiC.PROPERTY_TOUCH_ENABLED, false);
// We have traditionally always made the label untouchable, but since
// version 3.0.0 we support explore-by-touch on ICS and above, so for
// accessibility purposes we should not be disabling touch if
// accessibility is currently turned on.
if (!ICS_OR_GREATER || !TiApplication.getInstance().getAccessibilityManager().isEnabled()) {
rp.setProperty(TiC.PROPERTY_TOUCH_ENABLED, false);
}
}
if (views == null) {
views = new ArrayList<TiUIView>();
Expand Down Expand Up @@ -218,7 +230,7 @@ public void setRowData(TableViewRowProxy rp) {
// Handle right image
boolean clearRightImage = true;
// It's one or the other, check or child. If you set them both, child's gonna win.
HashMap props = rp.getProperties();
HashMap<String, Object> props = rp.getProperties();
if (props.containsKey(TiC.PROPERTY_HAS_CHECK)) {
if (TiConvert.toBoolean(props, TiC.PROPERTY_HAS_CHECK)) {
if (hasCheckDrawable == null) {
Expand Down Expand Up @@ -288,6 +300,18 @@ public void setRowData(TableViewRowProxy rp) {
// no children means that this is an old-style row
refreshOldStyleRow();
}

if (ICS_OR_GREATER) {
Object accessibilityHiddenVal = rp.getProperty(TiC.PROPERTY_ACCESSIBILITY_HIDDEN);
if (accessibilityHiddenVal != null) {
boolean hidden = TiConvert.toBoolean(accessibilityHiddenVal);
if (hidden) {
ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO);
} else {
ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO);
}
}
}
}

protected boolean hasView(TiUIView view) {
Expand Down Expand Up @@ -433,7 +457,6 @@ private KrollDict filterProperties(KrollDict d) {

@Override
public boolean hasSelector() {
KrollDict d = getRowProxy().getProperties();
TableViewRowProxy rowProxy = getRowProxy();
return rowProxy.hasProperty(TiC.PROPERTY_BACKGROUND_SELECTED_IMAGE)
|| rowProxy.hasProperty(TiC.PROPERTY_BACKGROUND_SELECTED_COLOR);
Expand Down
2 changes: 2 additions & 0 deletions android/titanium/src/java/org/appcelerator/titanium/TiC.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
* These are sorted alphabetically.
*/
public class TiC

{
public static final int API_LEVEL_HONEYCOMB = 11;
public static final int API_LEVEL_ICE_CREAM_SANDWICH = 14;
public static final int API_LEVEL_JELLY_BEAN = 16;
public static final String ERROR_PROPERTY_CODE = "code";
public static final String ERROR_PROPERTY_ERRORCODE = "errorcode";
public static final String ERROR_PROPERTY_MESSAGE = "message";
Expand Down