Updated a11y to have more descriptive text and clean up the talkback from the forecast adapter.
This commit is contained in:
@@ -196,9 +196,13 @@ public class DetailFragment extends Fragment implements LoaderManager.LoaderCall
|
|||||||
// Get description from weather condition ID
|
// Get description from weather condition ID
|
||||||
String description = Utility.getStringForWeatherCondition(getActivity(), weatherId);
|
String description = Utility.getStringForWeatherCondition(getActivity(), weatherId);
|
||||||
mDescriptionView.setText(description);
|
mDescriptionView.setText(description);
|
||||||
|
mDescriptionView.setContentDescription(getString(R.string.a11y_forecast, description));
|
||||||
|
|
||||||
// For accessibility, add a content description to the icon field
|
// For accessibility, add a content description to the icon field. Because the ImageView
|
||||||
mIconView.setContentDescription(description);
|
// is independently focusable, it's better to have a description of the image. Using
|
||||||
|
// null is appropriate when the image is purely decorative or when the image already
|
||||||
|
// has text describing it in the same UI component.
|
||||||
|
mIconView.setContentDescription(getString(R.string.a11y_forecast_icon, description));
|
||||||
|
|
||||||
// Read high temperature from cursor and update view
|
// Read high temperature from cursor and update view
|
||||||
boolean isMetric = Utility.isMetric(getActivity());
|
boolean isMetric = Utility.isMetric(getActivity());
|
||||||
@@ -206,24 +210,29 @@ public class DetailFragment extends Fragment implements LoaderManager.LoaderCall
|
|||||||
double high = data.getDouble(COL_WEATHER_MAX_TEMP);
|
double high = data.getDouble(COL_WEATHER_MAX_TEMP);
|
||||||
String highString = Utility.formatTemperature(getActivity(), high);
|
String highString = Utility.formatTemperature(getActivity(), high);
|
||||||
mHighTempView.setText(highString);
|
mHighTempView.setText(highString);
|
||||||
|
mHighTempView.setContentDescription(getString(R.string.a11y_high_temp, highString));
|
||||||
|
|
||||||
// Read low temperature from cursor and update view
|
// Read low temperature from cursor and update view
|
||||||
double low = data.getDouble(COL_WEATHER_MIN_TEMP);
|
double low = data.getDouble(COL_WEATHER_MIN_TEMP);
|
||||||
String lowString = Utility.formatTemperature(getActivity(), low);
|
String lowString = Utility.formatTemperature(getActivity(), low);
|
||||||
mLowTempView.setText(lowString);
|
mLowTempView.setText(lowString);
|
||||||
|
mLowTempView.setContentDescription(getString(R.string.a11y_low_temp, lowString));
|
||||||
|
|
||||||
// Read humidity from cursor and update view
|
// Read humidity from cursor and update view
|
||||||
float humidity = data.getFloat(COL_WEATHER_HUMIDITY);
|
float humidity = data.getFloat(COL_WEATHER_HUMIDITY);
|
||||||
mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity));
|
mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity));
|
||||||
|
mHumidityView.setContentDescription(mHumidityView.getText());
|
||||||
|
|
||||||
// Read wind speed and direction from cursor and update view
|
// Read wind speed and direction from cursor and update view
|
||||||
float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED);
|
float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED);
|
||||||
float windDirStr = data.getFloat(COL_WEATHER_DEGREES);
|
float windDirStr = data.getFloat(COL_WEATHER_DEGREES);
|
||||||
mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr));
|
mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr));
|
||||||
|
mWindView.setContentDescription(mWindView.getText());
|
||||||
|
|
||||||
// Read pressure from cursor and update view
|
// Read pressure from cursor and update view
|
||||||
float pressure = data.getFloat(COL_WEATHER_PRESSURE);
|
float pressure = data.getFloat(COL_WEATHER_PRESSURE);
|
||||||
mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure));
|
mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure));
|
||||||
|
mPressureView.setContentDescription(mPressureView.getText());
|
||||||
|
|
||||||
// We still need this for the share intent
|
// We still need this for the share intent
|
||||||
mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low);
|
mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low);
|
||||||
|
|||||||
@@ -115,20 +115,23 @@ public class ForecastAdapter extends CursorAdapter {
|
|||||||
String description = Utility.getStringForWeatherCondition(context, weatherId);
|
String description = Utility.getStringForWeatherCondition(context, weatherId);
|
||||||
// Find TextView and set weather forecast on it
|
// Find TextView and set weather forecast on it
|
||||||
viewHolder.descriptionView.setText(description);
|
viewHolder.descriptionView.setText(description);
|
||||||
|
viewHolder.descriptionView.setContentDescription(context.getString(R.string.a11y_forecast, description));
|
||||||
|
|
||||||
// For accessibility, add a content description to the icon field
|
// For accessibility, we don't want a content description for the icon field
|
||||||
viewHolder.iconView.setContentDescription(description);
|
// because the information is repeated in the description view and the icon
|
||||||
|
// is not individually selectable
|
||||||
// Read user preference for metric or imperial temperature units
|
|
||||||
boolean isMetric = Utility.isMetric(context);
|
|
||||||
|
|
||||||
// Read high temperature from cursor
|
// Read high temperature from cursor
|
||||||
double high = cursor.getDouble(ForecastFragment.COL_WEATHER_MAX_TEMP);
|
String high = Utility.formatTemperature(
|
||||||
viewHolder.highTempView.setText(Utility.formatTemperature(context, high));
|
context, cursor.getDouble(ForecastFragment.COL_WEATHER_MAX_TEMP));
|
||||||
|
viewHolder.highTempView.setText(high);
|
||||||
|
viewHolder.highTempView.setContentDescription(context.getString(R.string.a11y_high_temp, high));
|
||||||
|
|
||||||
// Read low temperature from cursor
|
// Read low temperature from cursor
|
||||||
double low = cursor.getDouble(ForecastFragment.COL_WEATHER_MIN_TEMP);
|
String low = Utility.formatTemperature(
|
||||||
viewHolder.lowTempView.setText(Utility.formatTemperature(context, low));
|
context, cursor.getDouble(ForecastFragment.COL_WEATHER_MIN_TEMP));
|
||||||
|
viewHolder.lowTempView.setText(low);
|
||||||
|
viewHolder.lowTempView.setContentDescription(context.getString(R.string.a11y_low_temp, low));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUseTodayLayout(boolean useTodayLayout) {
|
public void setUseTodayLayout(boolean useTodayLayout) {
|
||||||
|
|||||||
@@ -123,6 +123,12 @@
|
|||||||
<string name="empty_forecast_list_server_error">No weather information available. The server is not returning valid data. Please check for an updated version of Sunshine.</string>
|
<string name="empty_forecast_list_server_error">No weather information available. The server is not returning valid data. Please check for an updated version of Sunshine.</string>
|
||||||
<string name="empty_forecast_list_invalid_location">No weather information available. The location in settings is not recognized by the weather server.</string>
|
<string name="empty_forecast_list_invalid_location">No weather information available. The location in settings is not recognized by the weather server.</string>
|
||||||
|
|
||||||
|
<!-- A11y -->
|
||||||
|
<string name="a11y_forecast">Forecast: <xliff:g id="condition">%1$s</xliff:g></string>
|
||||||
|
<string name="a11y_forecast_icon">Forecast icon: <xliff:g id="condition">%1$s</xliff:g></string>
|
||||||
|
<string name="a11y_high_temp">High: <xliff:g id="high">%1$s</xliff:g></string>
|
||||||
|
<string name="a11y_low_temp">Low: <xliff:g id="low">%1$s</xliff:g></string>
|
||||||
|
|
||||||
<!-- Weather Conditions -->
|
<!-- Weather Conditions -->
|
||||||
<string name="condition_2xx">Storm</string>
|
<string name="condition_2xx">Storm</string>
|
||||||
<string name="condition_3xx">Drizzle</string>
|
<string name="condition_3xx">Drizzle</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user