Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue-714: Added accessibility labels to weather symbols #732

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,10 @@ protected void setWidgetData(JSONArray announcementsJson, SharedPreferencesHelpe

// ** set the weather icon

String weatherSymbol = first.getString("smartSymbol");
int weatherSymbol = first.getInt("smartSymbol");
int drawableResId = context.getResources().getIdentifier("s_" + weatherSymbol + (theme.equals(LIGHT) ? "_light" : "_dark"), "drawable", context.getPackageName());
widgetRemoteViews.setImageViewResource(R.id.weatherIconImageView, drawableResId);
widgetRemoteViews.setContentDescription(R.id.weatherIconImageView, getSymbolTranslation(weatherSymbol));

// Update time TODO: should be hidden for release
AnttiRumpunen marked this conversation as resolved.
Show resolved Hide resolved
widgetRemoteViews.setTextViewText(R.id.updateTimeTextView, DateFormat.getTimeInstance().format(new Date()));
Expand Down Expand Up @@ -838,4 +839,14 @@ protected int getFirstFutureTimeIndex(JSONArray data) throws JSONException {
// if no future time found
return -1;
}

protected String getSymbolTranslation(int symbol) {
// > 100 is night version, but we can use day symbol translation
int symbolId = context.getResources().getIdentifier(
symbol > 100 ? "s_"+(symbol-100) : "s_"+symbol,
"string",
context.getPackageName()
);
return context.getString(symbolId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected void setWidgetData(JSONArray announcementsJson, SharedPreferencesHelpe
// time at the selected location
String localTime = forecast.getString("localtime");
String temperature = forecast.getString("temperature");
String weatherSymbol = forecast.getString("smartSymbol");
int weatherSymbol = forecast.getInt("smartSymbol");

// get timeTextView0 or timeTextView1 etc. based on i from widgetRemoteViews
int timeTextViewId = context.getResources().getIdentifier("timeTextView" + i, "id", context.getPackageName());
Expand All @@ -86,6 +86,7 @@ protected void setWidgetData(JSONArray announcementsJson, SharedPreferencesHelpe

int drawableResId = context.getResources().getIdentifier("s_" + weatherSymbol + (theme.equals(LIGHT) ? "_light" : "_dark"), "drawable", context.getPackageName());
widgetRemoteViews.setImageViewResource(weatherIconImageViewId, drawableResId);
widgetRemoteViews.setContentDescription(weatherIconImageViewId, getSymbolTranslation(weatherSymbol));
}

// Update time TODO: should be hidden for release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ protected void setWidgetData(JSONArray announcementsJson, SharedPreferencesHelpe
widgetRemoteViews.setTextViewText(R.id.timeTextView, formattedTime);

String temperature = forecast.getString("temperature");
String weatherSymbol = forecast.getString("smartSymbol");
int weatherSymbol = forecast.getInt("smartSymbol");

widgetRemoteViews.setTextViewText(R.id.temperatureTextView, addPlusIfNeeded(temperature) + "°");

int drawableResId = context.getResources().getIdentifier("s_" + weatherSymbol + (theme.equals(LIGHT) ? "_light" : "_dark"), "drawable", context.getPackageName());
widgetRemoteViews.setImageViewResource(R.id.weatherIconImageView, drawableResId);
widgetRemoteViews.setContentDescription(R.id.weatherIconImageView, getSymbolTranslation(weatherSymbol));

// next iteration in loop
continue;
Expand All @@ -92,7 +93,7 @@ protected void setWidgetData(JSONArray announcementsJson, SharedPreferencesHelpe
// time at the selected location
String localTime = forecast.getString("localtime");
String temperature = forecast.getString("temperature");
String weatherSymbol = forecast.getString("smartSymbol");
int weatherSymbol = forecast.getInt("smartSymbol");

// j = weather row layout index
int j = i - 1;
Expand All @@ -112,6 +113,7 @@ protected void setWidgetData(JSONArray announcementsJson, SharedPreferencesHelpe

int drawableResId = context.getResources().getIdentifier("s_" + weatherSymbol + (theme.equals(LIGHT) ? "_light" : "_dark"), "drawable", context.getPackageName());
widgetRemoteViews.setImageViewResource(weatherIconImageViewId, drawableResId);
widgetRemoteViews.setContentDescription(weatherIconImageViewId, getSymbolTranslation(weatherSymbol));
}

// Get the current time
Expand Down
Binary file removed android/app/src/main/res/drawable-mdpi/fmi_logo.png
Binary file not shown.
Binary file removed android/app/src/main/res/drawable-xhdpi/basic.png
Binary file not shown.
Binary file removed android/app/src/main/res/drawable-xhdpi/easter.png
Binary file not shown.
Binary file not shown.
Binary file removed android/app/src/main/res/drawable-xhdpi/hot.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed android/app/src/main/res/drawable-xhdpi/newyear.png
Binary file not shown.
Binary file removed android/app/src/main/res/drawable-xhdpi/raining.png
Binary file not shown.
Binary file not shown.
Binary file removed android/app/src/main/res/drawable-xhdpi/vappu.png
Binary file not shown.
Binary file removed android/app/src/main/res/drawable-xhdpi/windy.png
Binary file not shown.
Binary file removed android/app/src/main/res/drawable-xhdpi/winter.png
Binary file not shown.
Binary file removed android/app/src/main/res/drawable-xhdpi/xmas.png
Binary file not shown.
Binary file removed android/app/src/main/res/drawable/whitelogo.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal"
android:contentDescription="TODO"
tools:src="@drawable/s_32_light" />

<TextView
Expand Down Expand Up @@ -105,7 +104,6 @@
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal"
android:contentDescription="TODO"
tools:src="@drawable/s_32_light" />

<TextView
Expand Down Expand Up @@ -143,7 +141,6 @@
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal"
android:contentDescription="TODO"
tools:src="@drawable/s_32_light" />

<TextView
Expand Down Expand Up @@ -181,7 +178,6 @@
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal"
android:contentDescription="TODO"
tools:src="@drawable/s_32_light" />

<TextView
Expand Down Expand Up @@ -219,7 +215,6 @@
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal"
android:contentDescription="TODO"
tools:src="@drawable/s_32_light" />

<TextView
Expand All @@ -240,6 +235,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/fmi_logo_blue"
android:importantForAccessibility="no"
android:visibility="gone" />

<TextView
Expand Down Expand Up @@ -293,6 +289,7 @@
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_marginEnd="5dp"
android:importantForAccessibility="no"
android:background="@drawable/ic_info_blue" />

<LinearLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_marginEnd="18dp"
android:contentDescription="TODO"
tools:src="@drawable/s_32_light" />

<TextView
Expand Down Expand Up @@ -166,7 +165,6 @@
android:layout_above="@id/temperatureTextView0"
android:layout_below="@id/timeTextView0"
android:layout_gravity="center"
android:contentDescription="TODO"
tools:src="@drawable/s_32_light" />

<TextView
Expand Down Expand Up @@ -207,7 +205,6 @@
android:layout_above="@id/temperatureTextView1"
android:layout_below="@id/timeTextView1"
android:layout_gravity="center"
android:contentDescription="TODO"
tools:src="@drawable/s_32_light" />

<TextView
Expand Down Expand Up @@ -248,7 +245,6 @@
android:layout_above="@id/temperatureTextView2"
android:layout_below="@id/timeTextView2"
android:layout_gravity="center"
android:contentDescription="TODO"
tools:src="@drawable/s_32_light" />

<TextView
Expand Down Expand Up @@ -289,7 +285,6 @@
android:layout_above="@id/temperatureTextView3"
android:layout_below="@id/timeTextView3"
android:layout_gravity="center"
android:contentDescription="TODO"
tools:src="@drawable/s_32_light" />

<TextView
Expand Down Expand Up @@ -330,7 +325,6 @@
android:layout_above="@id/temperatureTextView4"
android:layout_below="@id/timeTextView4"
android:layout_gravity="center"
android:contentDescription="TODO"
tools:src="@drawable/s_32_light" />

<TextView
Expand Down Expand Up @@ -374,7 +368,6 @@
android:layout_height="27dp"
android:layout_alignParentStart="true"
android:layout_marginTop="11dp"
android:contentDescription="TODO"
android:src="@drawable/fmi_logo_blue" />

<TextView
Expand Down Expand Up @@ -417,6 +410,7 @@
android:layout_height="22dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="5dp"
android:importantForAccessibility="no"
android:background="@drawable/ic_info_blue" />

<LinearLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_marginEnd="7dp"
android:contentDescription="TODO"
tools:src="@drawable/s_32_light" />

<TextView
Expand All @@ -74,6 +73,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/fmi_logo_blue"
android:importantForAccessibility="no"
android:visibility="gone" />

<TextView
Expand Down
30 changes: 0 additions & 30 deletions android/app/src/main/res/layout/weathercell.xml

This file was deleted.

35 changes: 0 additions & 35 deletions android/app/src/main/res/layout/weathercellsmall.xml

This file was deleted.

60 changes: 0 additions & 60 deletions android/app/src/main/res/layout/widgetng.xml

This file was deleted.

45 changes: 45 additions & 0 deletions android/app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,49 @@
<string name="add_favorite_locations_explanation">Please add your favorite places in the Weather app, if you want to use widget without location services.</string>
<string name="add_more_favorite_locations">Add more favorite locations</string>
<string name="allow_background_location_service">Please allow the Weather app background location service (Allow all the time) use your current location to show weather near you.</string>
<string name="s_1">Clear</string>
<string name="s_2">Mostly clear</string>
<string name="s_4">Partly cloudy</string>
<string name="s_6">Mostly cloudy</string>
<string name="s_7">Overcast</string>
<string name="s_9">Fog</string>
<string name="s_11">Drizzle</string>
<string name="s_14">Freezing drizzle</string>
<string name="s_17">Freezing rain</string>
<string name="s_21">Isolated showers</string>
<string name="s_24">Scattered showers</string>
<string name="s_27">Showers</string>
<string name="s_31">Partly cloudy and periods of light rain</string>
<string name="s_32">Partly cloudy and periods of moderate rain</string>
<string name="s_33">Partly cloudy and periods of heavy rain</string>
<string name="s_34">Mostly cloudy and periods of light rain</string>
<string name="s_35">Mostly cloudy and periods of moderate rain</string>
<string name="s_36">Mostly cloudy and periods of heavy rain</string>
<string name="s_37">Light rain</string>
<string name="s_38">Moderate rain</string>
<string name="s_39">Heavy rain</string>
<string name="s_41">Isolated light sleet showers</string>
<string name="s_42">Isolated moderate sleet showers</string>
<string name="s_43">Isolated heavy sleet showers</string>
<string name="s_44">Scattered light sleet showers</string>
<string name="s_45">Scattered moderate sleet showers</string>
<string name="s_46">Scattered heavy sleet showers</string>
<string name="s_47">Light sleet</string>
<string name="s_48">Moderate sleet</string>
<string name="s_49">Heavy sleet</string>
<string name="s_51">Isolated light snow showers</string>
<string name="s_52">Isolated moderate snow showers</string>
<string name="s_53">Isolated heavy snow showers</string>
<string name="s_54">Scattered light snow showers</string>
<string name="s_55">Scattered moderate snow showers</string>
<string name="s_56">Scattered heavy snow showers</string>
<string name="s_57">Light snowfall</string>
<string name="s_58">Moderate snowfall</string>
<string name="s_59">Heavy snowfall</string>
<string name="s_61">Isolated hail showers</string>
<string name="s_64">Scattered hail showers</string>
<string name="s_67">Hail showers</string>
<string name="s_71">Isolated thundershowers</string>
<string name="s_74">Scattered thundershowers</string>
<string name="s_77">Thundershowers</string>
</resources>
Loading