Improved accessibility by providing content description for widgets.

This commit is contained in:
Igor B. Poretsky 2013-03-01 04:28:59 +04:00
parent ee3b5aab21
commit 6ea8d82000
9 changed files with 39 additions and 12 deletions

View file

@ -3,7 +3,7 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:keepScreenOn="true"> android:layout_height="fill_parent" android:keepScreenOn="true">
<net.osmand.plus.views.OsmandMapTileView android:id="@+id/MapView" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <net.osmand.plus.views.OsmandMapTileView android:id="@+id/MapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:contentDescription="@string/map_view"/>
<LinearLayout android:layout_width="wrap_content" android:id="@+id/RouteLayout" android:orientation="horizontal" android:layout_height="wrap_content" android:layout_gravity="bottom|center" android:layout_marginBottom="12dp"> <LinearLayout android:layout_width="wrap_content" android:id="@+id/RouteLayout" android:orientation="horizontal" android:layout_height="wrap_content" android:layout_gravity="bottom|center" android:layout_marginBottom="12dp">
<Button android:contentDescription="@string/previous_button" android:layout_width="wrap_content" android:id="@+id/PreviousButton" android:layout_height="wrap_content" android:background="@android:drawable/ic_media_previous"/> <Button android:contentDescription="@string/previous_button" android:layout_width="wrap_content" android:id="@+id/PreviousButton" android:layout_height="wrap_content" android:background="@android:drawable/ic_media_previous"/>

View file

@ -3,7 +3,7 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:keepScreenOn="true" android:clipChildren="false"> android:layout_height="fill_parent" android:keepScreenOn="true" android:clipChildren="false">
<net.osmand.plus.views.OsmandMapTileView android:id="@+id/MapView" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <net.osmand.plus.views.OsmandMapTileView android:id="@+id/MapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:contentDescription="@string/map_view"/>
<LinearLayout android:layout_width="wrap_content" android:id="@+id/RouteLayout" android:orientation="horizontal" android:layout_height="wrap_content" <LinearLayout android:layout_width="wrap_content" android:id="@+id/RouteLayout" android:orientation="horizontal" android:layout_height="wrap_content"
android:layout_marginBottom="12dp" android:layout_gravity="bottom|center" > android:layout_marginBottom="12dp" android:layout_gravity="bottom|center" >

View file

@ -1126,4 +1126,7 @@
<string name="prefer_in_routing_title">Предпочитать…</string> <string name="prefer_in_routing_title">Предпочитать…</string>
<string name="prefer_in_routing_descr">Предпочитать автомагистрали</string> <string name="prefer_in_routing_descr">Предпочитать автомагистрали</string>
<string name="tip_recent_changes_1_2_t">"Изменения в 1.2: "</string> <string name="tip_recent_changes_1_2_t">"Изменения в 1.2: "</string>
</resources> <string name="item_checked">отмечено</string>
<string name="item_unchecked">не отмечено</string>
<string name="map_view">Карта</string>
</resources>

View file

@ -9,6 +9,9 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="item_checked">checked</string>
<string name="item_unchecked">unchecked</string>
<string name="map_view">Map</string>
<string name="prefer_motorways">Prefer motorways</string> <string name="prefer_motorways">Prefer motorways</string>
<string name="prefer_in_routing_title">Prefer&#8230;</string> <string name="prefer_in_routing_title">Prefer&#8230;</string>
<string name="prefer_in_routing_descr">Prefer motorways</string> <string name="prefer_in_routing_descr">Prefer motorways</string>

View file

@ -83,6 +83,7 @@ public class PluginsActivity extends OsmandListActivity {
TextView nameView = (TextView) row.findViewById(R.id.plugin_name); TextView nameView = (TextView) row.findViewById(R.id.plugin_name);
nameView.setText(plugin.getName()); nameView.setText(plugin.getName());
nameView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.list_activities_plugin_menu_symbol), null, getResources().getDrawable(resourceId), null); nameView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.list_activities_plugin_menu_symbol), null, getResources().getDrawable(resourceId), null);
nameView.setContentDescription(plugin.getName() + " " + getString(toBeEnabled ? R.string.item_checked : R.string.item_unchecked));
TextView description = (TextView) row.findViewById(R.id.plugin_descr); TextView description = (TextView) row.findViewById(R.id.plugin_descr);
description.setText(plugin.getDescription()); description.setText(plugin.getDescription());

View file

@ -15,6 +15,8 @@ public abstract class MapInfoControl extends View implements MapControlUpdateabl
Rect padding = new Rect(); Rect padding = new Rect();
int shadowColor = Color.WHITE; int shadowColor = Color.WHITE;
private String contentTitle;
public MapInfoControl(Context ctx) { public MapInfoControl(Context ctx) {
super(ctx); super(ctx);
} }
@ -25,6 +27,17 @@ public abstract class MapInfoControl extends View implements MapControlUpdateabl
super.setBackgroundDrawable(d); super.setBackgroundDrawable(d);
} }
@Override
public void setContentDescription(CharSequence text) {
if (contentTitle != null)
super.setContentDescription(contentTitle + " " + text); //$NON-NLS-1$
else super.setContentDescription(text);
}
public void setContentTitle(String text) {
contentTitle = text;
super.setContentDescription(text);
}
public void setWDimensions(int w, int h){ public void setWDimensions(int w, int h){
setMeasuredDimension(w + padding.left + padding.right, h + padding.top + padding.bottom); setMeasuredDimension(w + padding.left + padding.right, h + padding.top + padding.bottom);

View file

@ -133,6 +133,8 @@ public class MapInfoControls {
ii.visibleModes.add(ms); ii.visibleModes.add(ms);
} }
} }
if (m != null)
m.setContentDescription(m.getContext().getString(messageId));
ii.drawable = drawable; ii.drawable = drawable;
ii.messageId = messageId; ii.messageId = messageId;
ii.m = m; ii.m = m;
@ -174,6 +176,8 @@ public class MapInfoControls {
ii.visibleCollapsible.add(ms); ii.visibleCollapsible.add(ms);
} }
} }
if (m != null)
m.setContentTitle(m.getContext().getString(messageId));
ii.drawable = drawable; ii.drawable = drawable;
ii.messageId = messageId; ii.messageId = messageId;
ii.m = m; ii.m = m;

View file

@ -732,22 +732,16 @@ public class MapInfoLayer extends OsmandMapLayer {
ImageView configuration = new ImageView(map); ImageView configuration = new ImageView(map);
Drawable drawable = view.getResources().getDrawable(R.drawable.widget_config); Drawable drawable = view.getResources().getDrawable(R.drawable.widget_config);
configuration.setBackgroundDrawable(drawable); configuration.setBackgroundDrawable(drawable);
configuration.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openViewConfigureDialog();
}
});
fl.addView(configuration, fparams); fl.addView(configuration, fparams);
fparams = new FrameLayout.LayoutParams(drawable.getMinimumWidth(), drawable.getMinimumHeight()); fparams = new FrameLayout.LayoutParams(drawable.getMinimumWidth(), drawable.getMinimumHeight());
progressBar = new View(view.getContext()); progressBar = new View(view.getContext());
progressBar.setOnClickListener(new View.OnClickListener() { fl.addView(progressBar, fparams);
fl.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
openViewConfigureDialog(); openViewConfigureDialog();
} }
}); });
fl.addView(progressBar, fparams);
return fl; return fl;
} }
private View createGlobus(){ private View createGlobus(){
@ -943,8 +937,10 @@ public class MapInfoLayer extends OsmandMapLayer {
text += ".."; text += "..";
} }
setTextSize(TypedValue.COMPLEX_UNIT_PX, pp.getTextSize()); setTextSize(TypedValue.COMPLEX_UNIT_PX, pp.getTextSize());
setContentDescription(text);
} else { } else {
setTextSize(TypedValue.COMPLEX_UNIT_PX, 7); setTextSize(TypedValue.COMPLEX_UNIT_PX, 7);
setContentDescription(getResources().getString(R.string.map_widget_top_text));
} }
setText(text); setText(text);
invalidate(); invalidate();

View file

@ -43,6 +43,13 @@ public class TextInfoControl extends MapInfoControl {
public void setText(String text, String subtext) { public void setText(String text, String subtext) {
this.text = text; this.text = text;
this.subtext = subtext; this.subtext = subtext;
if (text != null) {
if (subtext != null)
setContentDescription(text + " " + subtext); //$NON-NLS-1$
else setContentDescription(text);
} else {
setContentDescription(subtext);
}
updateVisibility(text != null); updateVisibility(text != null);
requestLayout(); requestLayout();
invalidate(); invalidate();