Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] - add accessibility support to the Android SDK by applying …
Browse files Browse the repository at this point in the history
…content descriptions on Views overlain on the map.
  • Loading branch information
tobrun committed Mar 1, 2017
1 parent 34fef22 commit 7c9d8a6
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ public View getView(@NonNull MarkerView marker, @Nullable View convertView, @Non
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.imageView.setImageBitmap(marker.getIcon().getBitmap());
viewHolder.imageView.setContentDescription(marker.getTitle());
return convertView;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ private void initialise(@NonNull final Context context, @NonNull final MapboxMap
ImageView attrView = (ImageView) view.findViewById(R.id.attributionView);
initalizeDrawingSurface(context, options);

// add accessibility support
setContentDescription(context.getString(R.string.mapbox_mapActionDescription));

// create native Map object
nativeMapView = new NativeMapView(this);

Expand Down Expand Up @@ -157,8 +160,6 @@ private void initialise(@NonNull final Context context, @NonNull final MapboxMap
attrView.setOnClickListener(new AttributionOnClickListener(context, transform));

// Ensure this view is interactable
setClickable(true);
setLongClickable(true);
setFocusable(true);
setFocusableInTouchMode(true);
requestDisallowInterceptTouchEvent(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public CompassView(Context context, AttributeSet attrs, int defStyleAttr) {

private void initialize(Context context) {
setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.mapbox_compass_icon));
setContentDescription(getResources().getString(R.string.mapbox_compassContentDescription));
setEnabled(false);

// Layout params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
<!-- Deprecated to use TextureView-->
<public name="mapbox_renderTextureMode" type="attr" />

<!-- Exposed content descriptions -->
<public name="mapbox_compassContentDescription" type="string" />
<public name="mapbox_attributionsIconContentDescription" type="string" />
<public name="mapbox_myLocationViewContentDescription" type="string" />
<public name="mapbox_logoContentDescription" type="string" />

<!-- Exposed styles -->
<public name="mapbox_style_mapbox_streets" type="string" />
<public name="mapbox_style_emerald" type="string" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,34 @@
android:id="@+id/surfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
android:contentDescription="@null"
android:visibility="gone"/>

<FrameLayout
android:id="@+id/markerViewContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent" />
android:background="@android:color/transparent"
android:contentDescription="@null"/>

<com.mapbox.mapboxsdk.maps.widgets.MyLocationView
android:id="@+id/userLocationView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:contentDescription="@string/mapbox_myLocationViewContentDescription"/>

<com.mapbox.mapboxsdk.maps.widgets.CompassView
android:id="@+id/compassView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:contentDescription="@string/mapbox_compassContentDescription"/>

<ImageView
android:id="@+id/logoView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/mapbox_iconContentDescription"
android:src="@drawable/mapbox_logo_icon" />
android:contentDescription="@null"
android:src="@drawable/mapbox_logo_icon"/>

<ImageView
android:id="@+id/attributionView"
Expand All @@ -39,6 +43,6 @@
android:clickable="true"
android:contentDescription="@string/mapbox_attributionsIconContentDescription"
android:padding="7dp"
android:src="@drawable/mapbox_info_bg_selector" />
android:src="@drawable/mapbox_info_bg_selector"/>

</merge>
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
android:layout_alignParentLeft="true"
android:layout_marginBottom="@dimen/mapbox_eight_dp"
android:layout_marginLeft="@dimen/mapbox_eight_dp"
android:contentDescription="@string/mapbox_iconContentDescription"
android:src="@drawable/mapbox_logo_icon" />
android:contentDescription="@null"
android:src="@drawable/mapbox_logo_icon"/>

<ImageView
android:layout_width="wrap_content"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="mapbox_compassContentDescription">Map compass. Click to reset the map rotation to North.</string>
<string name="mapbox_attributionsIconContentDescription">Attribution icon. Click to show attribution dialog.</string>
<string name="mapbox_compassContentDescription">Map compass. Activate to reset the map rotation to North.</string>
<string name="mapbox_attributionsIconContentDescription">Attribution icon. Activate to show attribution dialog.</string>
<string name="mapbox_myLocationViewContentDescription">Location View. This shows your location on the map.</string>
<string name="mapbox_mapActionDescription">Showing a Map created with Mapbox. Scroll by dragging two fingers. Zoom by pinching two fingers.</string>
<string name="mapbox_attributionsDialogTitle">Mapbox Android SDK</string>
<string name="mapbox_attributionTelemetryTitle">Make Mapbox Maps Better</string>
<string name="mapbox_attributionTelemetryMessage">You are helping to make OpenStreetMap and Mapbox maps better by contributing anonymous usage data.</string>
<string name="mapbox_attributionTelemetryPositive">Agree</string>
<string name="mapbox_attributionTelemetryNegative">Disagree</string>
<string name="mapbox_attributionTelemetryNeutral">More info</string>
<string name="mapbox_iconContentDescription">The Mapbox logo.</string>
<string name="mapbox_infoWindowTitle">Title</string>
<string name="mapbox_infoWindowDescription">Description</string>
<string name="mapbox_infoWindowAddress">Address</string>
Expand Down

0 comments on commit 7c9d8a6

Please sign in to comment.