From 11af72be22aee558be987eff0ec8a4e5c8df3406 Mon Sep 17 00:00:00 2001 From: vrajdesai78 Date: Sun, 7 Aug 2022 01:09:53 +0530 Subject: [PATCH 1/8] content description added --- .../org/oppia/android/app/utility/ClickableAreasImage.kt | 1 + domain/src/main/assets/13.json | 9 +++++++++ domain/src/main/assets/13.textproto | 9 +++++++++ .../java/org/oppia/android/domain/util/StateRetriever.kt | 1 + model/src/main/proto/interaction_object.proto | 1 + 5 files changed, 21 insertions(+) diff --git a/app/src/main/java/org/oppia/android/app/utility/ClickableAreasImage.kt b/app/src/main/java/org/oppia/android/app/utility/ClickableAreasImage.kt index a1793e9656d..84983aa0924 100644 --- a/app/src/main/java/org/oppia/android/app/utility/ClickableAreasImage.kt +++ b/app/src/main/java/org/oppia/android/app/utility/ClickableAreasImage.kt @@ -136,6 +136,7 @@ class ClickableAreasImage( showOrHideRegion(newView, clickableArea) } } + newView.contentDescription = clickableArea.contentDescription it.addView(newView) } diff --git a/domain/src/main/assets/13.json b/domain/src/main/assets/13.json index d6daf4d73af..0cb3c0e8700 100644 --- a/domain/src/main/assets/13.json +++ b/domain/src/main/assets/13.json @@ -70,54 +70,63 @@ "imagePath": "Screen Shot 2015-02-18 at 3.51.49 AM_height_400_width_816.png", "labeledRegions": [{ "label": "Mercury", + "contentDescription": "You have selected planet Mercury", "region": { "regionType": "Rectangle", "area": [[0.010981758125126362, 0.09856376051902771], [0.04871760681271553, 0.17073357105255127]] } }, { "label": "Venus", + "contentDescription": "You have selected planet Venus", "region": { "regionType": "Rectangle", "area": [[0.03692515566945076, 0.1755448877811432], [0.10060440003871918, 0.2958278954029083]] } }, { "label": "Earth", + "contentDescription": "You have selected planet Earth", "region": { "regionType": "Rectangle", "area": [[0.08645345270633698, 0.10818640142679214], [0.15484967827796936, 0.22846941649913788]] } }, { "label": "Mars", + "contentDescription": "You have selected planet Mars", "region": { "regionType": "Rectangle", "area": [[0.14777420461177826, 0.1755448877811432], [0.1925855278968811, 0.27177131175994873]] } }, { "label": "Jupiter", + "contentDescription": "You have selected planet Jupiter", "region": { "regionType": "Rectangle", "area": [[0.19022704660892487, 0.060073189437389374], [0.572302520275116, 0.8154505491256714]] } }, { "label": "Saturn", + "contentDescription": "You have selected planet Saturn", "region": { "regionType": "Rectangle", "area": [[0.24918930232524872, 0.3679977059364319], [0.9968308210372925, 0.9934694170951843]] } }, { "label": "Uranus", + "contentDescription": "You have selected planet Uranus", "region": { "regionType": "Rectangle", "area": [[0.6642836332321167, 0.05045054852962494], [0.8152270317077637, 0.35356375575065613]] } }, { "label": "Neptune", + "contentDescription": "You have selected planet Neptune", "region": { "regionType": "Rectangle", "area": [[0.8246610164642334, 0.021582625806331635], [0.9402270317077637, 0.25252601504325867]] } }, { "label": "Pluto", + "contentDescription": "You have selected planet Pluto", "region": { "regionType": "Rectangle", "area": [[0.9402270317077637, 0.22365809977054596], [0.9779629111289978, 0.2958278954029083]] diff --git a/domain/src/main/assets/13.textproto b/domain/src/main/assets/13.textproto index 59c04319ecf..9d9265638c3 100644 --- a/domain/src/main/assets/13.textproto +++ b/domain/src/main/assets/13.textproto @@ -477,6 +477,7 @@ states { image_path: "Screen Shot 2015-02-18 at 3.51.49 AM_height_400_width_816.png" label_regions { label: "Mercury" + contentDescription: "You have selected planet Mercury" region { region_type: RECTANGLE area { @@ -493,6 +494,7 @@ states { } label_regions { label: "Venus" + contentDescription: "You have selected planet Venus" region { region_type: RECTANGLE area { @@ -509,6 +511,7 @@ states { } label_regions { label: "Earth" + contentDescription: "You have selected planet Earth" region { region_type: RECTANGLE area { @@ -525,6 +528,7 @@ states { } label_regions { label: "Mars" + contentDescription: "You have selected planet Mars" region { region_type: RECTANGLE area { @@ -541,6 +545,7 @@ states { } label_regions { label: "Jupiter" + contentDescription: "You have selected planet Jupiter" region { region_type: RECTANGLE area { @@ -557,6 +562,7 @@ states { } label_regions { label: "Saturn" + contentDescription: "You have selected planet Saturn" region { region_type: RECTANGLE area { @@ -573,6 +579,7 @@ states { } label_regions { label: "Uranus" + contentDescription: "You have selected planet Uranus" region { region_type: RECTANGLE area { @@ -589,6 +596,7 @@ states { } label_regions { label: "Neptune" + contentDescription: "You have selected planet Neptune" region { region_type: RECTANGLE area { @@ -605,6 +613,7 @@ states { } label_regions { label: "Pluto" + contentDescription: "You have selected planet Pluto" region { region_type: RECTANGLE area { diff --git a/domain/src/main/java/org/oppia/android/domain/util/StateRetriever.kt b/domain/src/main/java/org/oppia/android/domain/util/StateRetriever.kt index 71ac96f542c..97b1fe73dcf 100644 --- a/domain/src/main/java/org/oppia/android/domain/util/StateRetriever.kt +++ b/domain/src/main/java/org/oppia/android/domain/util/StateRetriever.kt @@ -727,6 +727,7 @@ class StateRetriever @Inject constructor() { private fun parseLabeledRegion(jsonObject: JSONObject): LabeledRegion { return LabeledRegion.newBuilder() .setLabel(jsonObject.getStringFromObject("label")) + .setContentDescription(jsonObject.getStringFromObject("contentDescription")) .setRegion(parseRegion(jsonObject.getJSONObject("region"))) .build() } diff --git a/model/src/main/proto/interaction_object.proto b/model/src/main/proto/interaction_object.proto index 1e7b95ed7ef..4a6128defc8 100644 --- a/model/src/main/proto/interaction_object.proto +++ b/model/src/main/proto/interaction_object.proto @@ -95,6 +95,7 @@ message ImageWithRegions { } Region region = 2; + string content_description = 3; } repeated LabeledRegion label_regions = 2; } From 79f693d874891374540af2c2ccaca82bf0e1c130 Mon Sep 17 00:00:00 2001 From: vrajdesai78 Date: Sun, 7 Aug 2022 01:49:26 +0530 Subject: [PATCH 2/8] tests updated --- ...ageRegionSelectionTestFragmentPresenter.kt | 6 +++- .../app/utility/ClickableAreasImage.kt | 7 +++- .../android/app/utility/RegionClickEvent.kt | 3 +- ...ImageRegionSelectionInteractionViewTest.kt | 36 +++++++++++++++---- 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/oppia/android/app/testing/ImageRegionSelectionTestFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/testing/ImageRegionSelectionTestFragmentPresenter.kt index abdcba85aef..058a8334426 100644 --- a/app/src/main/java/org/oppia/android/app/testing/ImageRegionSelectionTestFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/testing/ImageRegionSelectionTestFragmentPresenter.kt @@ -29,16 +29,19 @@ class ImageRegionSelectionTestFragmentPresenter @Inject constructor( return listOf( createLabeledRegion( "Region 3", + "You have selected Region 3", createPoint2d(0.24242424242424243f, 0.22400442477876106f) to createPoint2d(0.49242424242424243f, 0.7638274336283186f) ), createLabeledRegion( "Region 1", + "You have selected Region 1", createPoint2d(0.553030303030303f, 0.5470132743362832f) to createPoint2d(0.7613636363636364f, 0.7638274336283186f) ), createLabeledRegion( "Region 2", + "You have selected Region 2", createPoint2d(0.5454545454545454f, 0.22842920353982302f) to createPoint2d(0.7537878787878788f, 0.4540929203539823f) ) @@ -47,9 +50,10 @@ class ImageRegionSelectionTestFragmentPresenter @Inject constructor( private fun createLabeledRegion( label: String, + contentDescription: String, points: Pair ): LabeledRegion { - return LabeledRegion.newBuilder().setLabel(label) + return LabeledRegion.newBuilder().setLabel(label).setContentDescription(contentDescription) .setRegion( LabeledRegion.Region.newBuilder() .setRegionType(LabeledRegion.Region.RegionType.RECTANGLE) diff --git a/app/src/main/java/org/oppia/android/app/utility/ClickableAreasImage.kt b/app/src/main/java/org/oppia/android/app/utility/ClickableAreasImage.kt index 84983aa0924..30ba360afa7 100644 --- a/app/src/main/java/org/oppia/android/app/utility/ClickableAreasImage.kt +++ b/app/src/main/java/org/oppia/android/app/utility/ClickableAreasImage.kt @@ -159,7 +159,12 @@ class ClickableAreasImage( private fun showOrHideRegion(newView: View, clickableArea: ImageWithRegions.LabeledRegion) { resetRegionSelectionViews() - listener.onClickableAreaTouched(NamedRegionClickedEvent(clickableArea.label)) + listener.onClickableAreaTouched( + NamedRegionClickedEvent( + clickableArea.label, + clickableArea.contentDescription + ) + ) newView.setBackgroundResource(R.drawable.selected_region_background) } } diff --git a/app/src/main/java/org/oppia/android/app/utility/RegionClickEvent.kt b/app/src/main/java/org/oppia/android/app/utility/RegionClickEvent.kt index 7df8bad6fbb..45376256631 100644 --- a/app/src/main/java/org/oppia/android/app/utility/RegionClickEvent.kt +++ b/app/src/main/java/org/oppia/android/app/utility/RegionClickEvent.kt @@ -8,7 +8,8 @@ sealed class RegionClickedEvent * * @param regionLabel region name for the which [OnClickableAreaClickedListener] was called for. */ -data class NamedRegionClickedEvent(val regionLabel: String) : RegionClickedEvent() +data class NamedRegionClickedEvent(val regionLabel: String, val contentDescription: String) : + RegionClickedEvent() /** * Class to be used in case when [OnClickableAreaClickedListener] is called with an unspecified diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/ImageRegionSelectionInteractionViewTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/ImageRegionSelectionInteractionViewTest.kt index 0985f555568..54c5f4d0c73 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/ImageRegionSelectionInteractionViewTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/ImageRegionSelectionInteractionViewTest.kt @@ -156,7 +156,11 @@ class ImageRegionSelectionInteractionViewTest { capture(regionClickedEvent) ) assertThat(regionClickedEvent.value) - .isEqualTo(NamedRegionClickedEvent(regionLabel = "Region 3")) + .isEqualTo( + NamedRegionClickedEvent( + regionLabel = "Region 3", contentDescription = "You have selected Region 3" + ) + ) } } @@ -194,7 +198,11 @@ class ImageRegionSelectionInteractionViewTest { ) ) assertThat(regionClickedEvent.value) - .isEqualTo(NamedRegionClickedEvent(regionLabel = "Region 2")) + .isEqualTo( + NamedRegionClickedEvent( + regionLabel = "Region 2", contentDescription = "You have selected Region 2" + ) + ) } } @@ -254,7 +262,11 @@ class ImageRegionSelectionInteractionViewTest { ) ) assertThat(regionClickedEvent.value) - .isEqualTo(NamedRegionClickedEvent(regionLabel = "Region 2")) + .isEqualTo( + NamedRegionClickedEvent( + regionLabel = "Region 2", contentDescription = "You have selected Region 2" + ) + ) } } @@ -279,7 +291,11 @@ class ImageRegionSelectionInteractionViewTest { capture(regionClickedEvent) ) assertThat(regionClickedEvent.value) - .isEqualTo(NamedRegionClickedEvent(regionLabel = "Region 3")) + .isEqualTo( + NamedRegionClickedEvent( + regionLabel = "Region 3", contentDescription = "You have selected Region 3" + ) + ) } } @@ -321,7 +337,11 @@ class ImageRegionSelectionInteractionViewTest { capture(regionClickedEvent) ) assertThat(regionClickedEvent.value) - .isEqualTo(NamedRegionClickedEvent(regionLabel = "Region 3")) + .isEqualTo( + NamedRegionClickedEvent( + regionLabel = "Region 3", contentDescription = "You have selected Region 3" + ) + ) } } @@ -360,7 +380,11 @@ class ImageRegionSelectionInteractionViewTest { ) ) assertThat(regionClickedEvent.value) - .isEqualTo(NamedRegionClickedEvent(regionLabel = "Region 2")) + .isEqualTo( + NamedRegionClickedEvent( + regionLabel = "Region 2", contentDescription = "You have selected Region 2" + ) + ) } } From 99a24a26dad7a8b04a35377d864dbbf821b5c03e Mon Sep 17 00:00:00 2001 From: vrajdesai78 Date: Mon, 8 Aug 2022 21:38:20 +0530 Subject: [PATCH 3/8] KDoc and comment added --- .../main/java/org/oppia/android/app/utility/RegionClickEvent.kt | 2 ++ model/src/main/proto/interaction_object.proto | 1 + 2 files changed, 3 insertions(+) diff --git a/app/src/main/java/org/oppia/android/app/utility/RegionClickEvent.kt b/app/src/main/java/org/oppia/android/app/utility/RegionClickEvent.kt index 45376256631..77879dd3fd8 100644 --- a/app/src/main/java/org/oppia/android/app/utility/RegionClickEvent.kt +++ b/app/src/main/java/org/oppia/android/app/utility/RegionClickEvent.kt @@ -7,6 +7,8 @@ sealed class RegionClickedEvent * Class to be used in case when [OnClickableAreaClickedListener] is called with an specified region. * * @param regionLabel region name for the which [OnClickableAreaClickedListener] was called for. + * @param contentDescription content description for which [OnClickableAreaClickedListener] was + * called for. */ data class NamedRegionClickedEvent(val regionLabel: String, val contentDescription: String) : RegionClickedEvent() diff --git a/model/src/main/proto/interaction_object.proto b/model/src/main/proto/interaction_object.proto index 4a6128defc8..faea17b0691 100644 --- a/model/src/main/proto/interaction_object.proto +++ b/model/src/main/proto/interaction_object.proto @@ -95,6 +95,7 @@ message ImageWithRegions { } Region region = 2; + // Content description for selected image region. string content_description = 3; } repeated LabeledRegion label_regions = 2; From ce83d6485c1d30e77d0de03cb85298e54abe8c17 Mon Sep 17 00:00:00 2001 From: vrajdesai78 Date: Fri, 19 Aug 2022 21:19:41 +0530 Subject: [PATCH 4/8] textproto updated --- domain/src/main/assets/13.textproto | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/domain/src/main/assets/13.textproto b/domain/src/main/assets/13.textproto index 9d9265638c3..22d5d5f306e 100644 --- a/domain/src/main/assets/13.textproto +++ b/domain/src/main/assets/13.textproto @@ -477,7 +477,7 @@ states { image_path: "Screen Shot 2015-02-18 at 3.51.49 AM_height_400_width_816.png" label_regions { label: "Mercury" - contentDescription: "You have selected planet Mercury" + content_description: "You have selected planet Mercury" region { region_type: RECTANGLE area { @@ -494,7 +494,7 @@ states { } label_regions { label: "Venus" - contentDescription: "You have selected planet Venus" + content_description: "You have selected planet Venus" region { region_type: RECTANGLE area { @@ -511,7 +511,7 @@ states { } label_regions { label: "Earth" - contentDescription: "You have selected planet Earth" + content_description: "You have selected planet Earth" region { region_type: RECTANGLE area { @@ -528,7 +528,7 @@ states { } label_regions { label: "Mars" - contentDescription: "You have selected planet Mars" + content_description: "You have selected planet Mars" region { region_type: RECTANGLE area { @@ -545,7 +545,7 @@ states { } label_regions { label: "Jupiter" - contentDescription: "You have selected planet Jupiter" + content_description: "You have selected planet Jupiter" region { region_type: RECTANGLE area { @@ -562,7 +562,7 @@ states { } label_regions { label: "Saturn" - contentDescription: "You have selected planet Saturn" + content_description: "You have selected planet Saturn" region { region_type: RECTANGLE area { @@ -579,7 +579,7 @@ states { } label_regions { label: "Uranus" - contentDescription: "You have selected planet Uranus" + content_description: "You have selected planet Uranus" region { region_type: RECTANGLE area { @@ -596,7 +596,7 @@ states { } label_regions { label: "Neptune" - contentDescription: "You have selected planet Neptune" + content_description: "You have selected planet Neptune" region { region_type: RECTANGLE area { @@ -613,7 +613,7 @@ states { } label_regions { label: "Pluto" - contentDescription: "You have selected planet Pluto" + content_description: "You have selected planet Pluto" region { region_type: RECTANGLE area { From 1bd918365b9f278a1724d047b18ee58d6ec01d55 Mon Sep 17 00:00:00 2001 From: vrajdesai78 Date: Fri, 26 Aug 2022 16:57:09 +0530 Subject: [PATCH 5/8] kdoc comment updated --- model/src/main/proto/interaction_object.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/src/main/proto/interaction_object.proto b/model/src/main/proto/interaction_object.proto index faea17b0691..d2f2c2008b8 100644 --- a/model/src/main/proto/interaction_object.proto +++ b/model/src/main/proto/interaction_object.proto @@ -95,7 +95,7 @@ message ImageWithRegions { } Region region = 2; - // Content description for selected image region. + // Content description to be read by screen readers when the associated region is clicked. string content_description = 3; } repeated LabeledRegion label_regions = 2; From 84b0e36383513969f25eb0e372ab73296566fd07 Mon Sep 17 00:00:00 2001 From: vrajdesai78 Date: Mon, 29 Aug 2022 16:37:16 +0530 Subject: [PATCH 6/8] @param changed to @property in kdoc --- .../java/org/oppia/android/app/utility/RegionClickEvent.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/oppia/android/app/utility/RegionClickEvent.kt b/app/src/main/java/org/oppia/android/app/utility/RegionClickEvent.kt index 77879dd3fd8..59ae1a2445c 100644 --- a/app/src/main/java/org/oppia/android/app/utility/RegionClickEvent.kt +++ b/app/src/main/java/org/oppia/android/app/utility/RegionClickEvent.kt @@ -6,8 +6,8 @@ sealed class RegionClickedEvent /** * Class to be used in case when [OnClickableAreaClickedListener] is called with an specified region. * - * @param regionLabel region name for the which [OnClickableAreaClickedListener] was called for. - * @param contentDescription content description for which [OnClickableAreaClickedListener] was + * @property regionLabel region name for the which [OnClickableAreaClickedListener] was called for. + * @property contentDescription content description for which [OnClickableAreaClickedListener] was * called for. */ data class NamedRegionClickedEvent(val regionLabel: String, val contentDescription: String) : From 14c688cfe3f14c86bcdec5266e21897ec1d43e12 Mon Sep 17 00:00:00 2001 From: vrajdesai78 Date: Tue, 30 Aug 2022 14:17:29 +0530 Subject: [PATCH 7/8] TODO removed --- .../android/instrumentation/player/ExplorationPlayerTest.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/instrumentation/src/javatests/org/oppia/android/instrumentation/player/ExplorationPlayerTest.kt b/instrumentation/src/javatests/org/oppia/android/instrumentation/player/ExplorationPlayerTest.kt index 4bf77e7610b..0428901d3bf 100644 --- a/instrumentation/src/javatests/org/oppia/android/instrumentation/player/ExplorationPlayerTest.kt +++ b/instrumentation/src/javatests/org/oppia/android/instrumentation/player/ExplorationPlayerTest.kt @@ -58,7 +58,6 @@ class ExplorationPlayerTest { // Image Region Selection Interaction. val imageSelectionView = device.findObjectByRes("interaction_container_frame_layout") device.waitForRes("image_click_interaction_image_view") - // TODO(#3712): Use content description to fetch the image region. imageSelectionView.children.get(2).click() device.findObjectByText("SUBMIT").click() device.findObjectByText("CONTINUE").click() From 16439d69a74155ffec8f63786fec4c4bfa11c9dd Mon Sep 17 00:00:00 2001 From: vrajdesai78 Date: Tue, 4 Oct 2022 21:59:17 +0530 Subject: [PATCH 8/8] Updated issue number in ToDo --- .../android/instrumentation/player/ExplorationPlayerTest.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/instrumentation/src/javatests/org/oppia/android/instrumentation/player/ExplorationPlayerTest.kt b/instrumentation/src/javatests/org/oppia/android/instrumentation/player/ExplorationPlayerTest.kt index 0428901d3bf..ab9f8c9b16a 100644 --- a/instrumentation/src/javatests/org/oppia/android/instrumentation/player/ExplorationPlayerTest.kt +++ b/instrumentation/src/javatests/org/oppia/android/instrumentation/player/ExplorationPlayerTest.kt @@ -58,6 +58,7 @@ class ExplorationPlayerTest { // Image Region Selection Interaction. val imageSelectionView = device.findObjectByRes("interaction_container_frame_layout") device.waitForRes("image_click_interaction_image_view") + // TODO(#4639): Use content description to fetch the image region. imageSelectionView.children.get(2).click() device.findObjectByText("SUBMIT").click() device.findObjectByText("CONTINUE").click()