Skip to content

Commit

Permalink
fix(android): correct content description component (#12538)
Browse files Browse the repository at this point in the history
  • Loading branch information
garymathews committed Aug 19, 2021
1 parent 386c5cf commit db1a83a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -589,4 +589,9 @@ public int getTintColor()
{
return tintColor;
}

public ImageView getImageView()
{
return this.imageView;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class TiUIImageView extends TiUIView implements OnLifecycleEvent, Handler
private boolean firedLoad;
private ImageViewProxy imageViewProxy;
private int currentDuration;
private TiImageView view;

private ArrayList<TiDrawableReference> imageSources;
private TiDrawableReference defaultImageSource;
Expand All @@ -90,7 +91,7 @@ public TiUIImageView(final TiViewProxy proxy)

Log.d(TAG, "Creating an ImageView", Log.DEBUG_MODE);

TiImageView view = new TiImageView(proxy.getActivity(), proxy);
view = new TiImageView(proxy.getActivity(), proxy);

downloadListener = new TiDownloadListener() {
@Override
Expand Down Expand Up @@ -165,6 +166,30 @@ public void loadImageFailed()
// TODO proxy.getActivity().addOnLifecycleEventListener(this);
}

@Override
protected void applyContentDescription()
{
if (proxy == null || nativeView == null) {
return;
}
String contentDescription = composeContentDescription();
if (contentDescription != null) {
this.view.getImageView().setContentDescription(contentDescription);
}
}

@Override
protected void applyContentDescription(KrollDict properties)
{
if (proxy == null || nativeView == null) {
return;
}
String contentDescription = composeContentDescription(properties);
if (contentDescription != null) {
this.view.getImageView().setContentDescription(contentDescription);
}
}

@Override
public void setProxy(TiViewProxy proxy)
{
Expand All @@ -174,7 +199,7 @@ public void setProxy(TiViewProxy proxy)

private TiImageView getView()
{
return (TiImageView) nativeView;
return this.view;
}

protected View getParentView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,30 @@ public void processProperties(KrollDict d)
disableChangeEvent = false;
}

@Override
protected void applyContentDescription()
{
if (proxy == null || nativeView == null) {
return;
}
String contentDescription = composeContentDescription();
if (contentDescription != null) {
this.tv.setContentDescription(contentDescription);
}
}

@Override
protected void applyContentDescription(KrollDict properties)
{
if (proxy == null || nativeView == null) {
return;
}
String contentDescription = composeContentDescription(properties);
if (contentDescription != null) {
this.tv.setContentDescription(contentDescription);
}
}

private void updateTextField()
{
if (!field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2214,7 +2214,7 @@ private void resetPostAnimationValues()
animatedAlpha = Float.MIN_VALUE; // we use min val to signal no val.
}

private void applyContentDescription()
protected void applyContentDescription()
{
if (proxy == null || nativeView == null) {
return;
Expand All @@ -2225,7 +2225,7 @@ private void applyContentDescription()
}
}

private void applyContentDescription(KrollDict properties)
protected void applyContentDescription(KrollDict properties)
{
if (proxy == null || nativeView == null) {
return;
Expand Down

0 comments on commit db1a83a

Please sign in to comment.