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
|
||||
String description = Utility.getStringForWeatherCondition(getActivity(), weatherId);
|
||||
mDescriptionView.setText(description);
|
||||
mDescriptionView.setContentDescription(getString(R.string.a11y_forecast, description));
|
||||
|
||||
// For accessibility, add a content description to the icon field
|
||||
mIconView.setContentDescription(description);
|
||||
// For accessibility, add a content description to the icon field. Because the ImageView
|
||||
// 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
|
||||
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);
|
||||
String highString = Utility.formatTemperature(getActivity(), high);
|
||||
mHighTempView.setText(highString);
|
||||
mHighTempView.setContentDescription(getString(R.string.a11y_high_temp, highString));
|
||||
|
||||
// Read low temperature from cursor and update view
|
||||
double low = data.getDouble(COL_WEATHER_MIN_TEMP);
|
||||
String lowString = Utility.formatTemperature(getActivity(), low);
|
||||
mLowTempView.setText(lowString);
|
||||
mLowTempView.setContentDescription(getString(R.string.a11y_low_temp, lowString));
|
||||
|
||||
// Read humidity from cursor and update view
|
||||
float humidity = data.getFloat(COL_WEATHER_HUMIDITY);
|
||||
mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity));
|
||||
mHumidityView.setContentDescription(mHumidityView.getText());
|
||||
|
||||
// Read wind speed and direction from cursor and update view
|
||||
float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED);
|
||||
float windDirStr = data.getFloat(COL_WEATHER_DEGREES);
|
||||
mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr));
|
||||
mWindView.setContentDescription(mWindView.getText());
|
||||
|
||||
// Read pressure from cursor and update view
|
||||
float pressure = data.getFloat(COL_WEATHER_PRESSURE);
|
||||
mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure));
|
||||
mPressureView.setContentDescription(mPressureView.getText());
|
||||
|
||||
// We still need this for the share intent
|
||||
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);
|
||||
// Find TextView and set weather forecast on it
|
||||
viewHolder.descriptionView.setText(description);
|
||||
viewHolder.descriptionView.setContentDescription(context.getString(R.string.a11y_forecast, description));
|
||||
|
||||
// For accessibility, add a content description to the icon field
|
||||
viewHolder.iconView.setContentDescription(description);
|
||||
|
||||
// Read user preference for metric or imperial temperature units
|
||||
boolean isMetric = Utility.isMetric(context);
|
||||
// For accessibility, we don't want a content description for the icon field
|
||||
// because the information is repeated in the description view and the icon
|
||||
// is not individually selectable
|
||||
|
||||
// Read high temperature from cursor
|
||||
double high = cursor.getDouble(ForecastFragment.COL_WEATHER_MAX_TEMP);
|
||||
viewHolder.highTempView.setText(Utility.formatTemperature(context, high));
|
||||
String high = Utility.formatTemperature(
|
||||
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
|
||||
double low = cursor.getDouble(ForecastFragment.COL_WEATHER_MIN_TEMP);
|
||||
viewHolder.lowTempView.setText(Utility.formatTemperature(context, low));
|
||||
String low = Utility.formatTemperature(
|
||||
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) {
|
||||
|
||||
@@ -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_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 -->
|
||||
<string name="condition_2xx">Storm</string>
|
||||
<string name="condition_3xx">Drizzle</string>
|
||||
|
||||
Reference in New Issue
Block a user