From 55076a41c865bd0d58c4e3143d29192ddf6235ab Mon Sep 17 00:00:00 2001 From: "Igor B. Poretsky" Date: Sat, 30 Apr 2016 16:43:31 +0300 Subject: [PATCH] Map widgets accessibility feedback fix. --- .../plus/views/mapwidgets/TextInfoWidget.java | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/TextInfoWidget.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/TextInfoWidget.java index d3fdcf1839..f399c4632c 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/TextInfoWidget.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/TextInfoWidget.java @@ -7,6 +7,7 @@ import android.app.Activity; import android.graphics.Paint.Style; import android.graphics.Typeface; import android.graphics.drawable.Drawable; +import android.text.TextUtils; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageView; @@ -99,12 +100,17 @@ public class TextInfoWidget { return isNight; } - public void setContentDescription(CharSequence text) { - if (contentTitle != null) { - view.setContentDescription(contentTitle + " " + text); //$NON-NLS-1$ - } else { - view.setContentDescription(text); + private CharSequence combine(CharSequence text, CharSequence subtext) { + if (TextUtils.isEmpty(text)) { + return subtext; + } else if (TextUtils.isEmpty(subtext)) { + return text; } + return text + " " + subtext; //$NON-NLS-1$ + } + + public void setContentDescription(CharSequence text) { + view.setContentDescription(combine(contentTitle, text)); } public void setContentTitle(int messageId) { @@ -113,7 +119,7 @@ public class TextInfoWidget { public void setContentTitle(String text) { contentTitle = text; - view.setContentDescription(text); + setContentDescription(combine(textView.getText(), smallTextView.getText())); } public void setText(String text, String subtext) { @@ -122,15 +128,7 @@ public class TextInfoWidget { } protected void setTextNoUpdateVisibility(String text, String subtext) { - if (text != null) { - if (subtext != null) { - setContentDescription(text + " " + subtext); //$NON-NLS-1$ - } else { - setContentDescription(text); - } - } else if(subtext != null){ - setContentDescription(subtext); - } + setContentDescription(combine(text, subtext)); // if(this.text != null && this.text.length() > 7) { // this.text = this.text.substring(0, 6) +".."; // }