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

Image region selection doesn't work in RTL layouts #3780

Closed
BenHenning opened this issue Sep 14, 2021 · 12 comments · Fixed by #3815
Closed

Image region selection doesn't work in RTL layouts #3780

BenHenning opened this issue Sep 14, 2021 · 12 comments · Fixed by #3815
Assignees
Labels
Z-ibt Temporary label for Ben to keep track of issues he's triaged.

Comments

@BenHenning
Copy link
Sponsor Member

Describe the bug
Image region selection has issues in RTL layouts. Regions don't seem to be selected when tapping around the image.

To Reproduce
Steps to reproduce the behavior:

  1. Open the Image Region Selection Exploration under First Test Topic (requires either playing through Prototype Exploration or unlocking it via the developer options menu)
  2. Try tapping around the image. Notice that no planets can be selected.

Expected behavior
Planets should be selected in this interaction. RTL shouldn't change how image region selection works.

Screenshots
None

Device

  • Device: Nexus 5X
@BenHenning
Copy link
Sponsor Member Author

/cc @rt4914 & @seanlip as FYI

@BenHenning
Copy link
Sponsor Member Author

@veena14cs assigning to you since I think this might've been missed during the RTL audit.

@BenHenning
Copy link
Sponsor Member Author

Follow-up: strangely, Saturn is still clickable but oddly. I can't seem to click on any of the other planets. I can't quite figure out how this is wrong.

@BenHenning BenHenning added this to the Alpha MR3 milestone Sep 15, 2021
@BenHenning
Copy link
Sponsor Member Author

/cc @anandwana001

@veena14cs
Copy link
Contributor

@veena14cs assigning to you since I think this might've been missed during the RTL audit.

Sure @BenHenning I will look into this.

@anandwana001
Copy link
Contributor

anandwana001 commented Sep 16, 2021

@veena14cs As I tried to look into this issue, in RTL, only Jupiter and Saturn are working, that too Jupiter is selecting the wrong one.

@rt4914 @veena14cs @BenHenning How are we defining the LabeledRegion for RTL? The current 2-Dimensional Point are of imge in LTR layout, but don't we need the RTL coordinates too?

@veena14cs
Copy link
Contributor

Canvas doesn't support RTL. We are using RectF() to draw region if I am not wrong. Co-ordinates for RTL is always from left-to-right instead of right-to-left.

@anandwana001
Copy link
Contributor

anandwana001 commented Sep 16, 2021

yes, @veena14cs Could you check addRegionViews function in ClickableAreasImage.kt file, and can we put some conditions like, in RTL, the region should get fliped to support RTL?

val imageRect = RectF(
          getXCoordinate(clickableArea.region.area.upperLeft.x),
          getYCoordinate(clickableArea.region.area.upperLeft.y),
          getXCoordinate(clickableArea.region.area.lowerRight.x),
          getYCoordinate(clickableArea.region.area.lowerRight.y)
        )

Sample Example SegmentedCircularProgressView, onDraw function.

@veena14cs
Copy link
Contributor

yes, @veena14cs Could you check addRegionViews function in ClickableAreasImage.kt file, and can we put some conditions like, in RTL, the region should get fliped to support RTL?

val imageRect = RectF(
          getXCoordinate(clickableArea.region.area.upperLeft.x),
          getYCoordinate(clickableArea.region.area.upperLeft.y),
          getXCoordinate(clickableArea.region.area.lowerRight.x),
          getYCoordinate(clickableArea.region.area.lowerRight.y)
        )

I tried to put some hardcoded values and also tried flipping left and right values but couldn't get it working. Let me try Sample Example SegmentedCircularProgressView, onDraw function.

@anandwana001
Copy link
Contributor

anandwana001 commented Sep 16, 2021

I tried to put a log to check the values we are passing in RectF() function and it is the same for LTR and RTL so there should be something else that is updating for RTL.

Log.d("imageRect", " ${clickableArea.region.area.upperLeft.x} - ${clickableArea.region.area.upperLeft.y} " +
  "- ${clickableArea.region.area.lowerRight.x} - ${clickableArea.region.area.lowerRight.y}")
LTR
2021-09-16 16:56:29.673 D/imageRect:  0.010981758 - 0.09856376 - 0.048717607 - 0.17073357
2021-09-16 16:56:29.681 D/imageRect:  0.036925156 - 0.17554489 - 0.1006044 - 0.2958279
2021-09-16 16:56:29.682 D/imageRect:  0.08645345 - 0.1081864 - 0.15484968 - 0.22846942
2021-09-16 16:56:29.682 D/imageRect:  0.1477742 - 0.17554489 - 0.19258553 - 0.2717713
2021-09-16 16:56:29.682 D/imageRect:  0.19022705 - 0.06007319 - 0.5723025 - 0.81545055
2021-09-16 16:56:29.687 D/imageRect:  0.2491893 - 0.3679977 - 0.9968308 - 0.9934694
2021-09-16 16:56:29.688 D/imageRect:  0.66428363 - 0.05045055 - 0.81522703 - 0.35356376
2021-09-16 16:56:29.688 D/imageRect:  0.824661 - 0.021582626 - 0.94022703 - 0.25252602
2021-09-16 16:56:29.690 D/imageRect:  0.94022703 - 0.2236581 - 0.9779629 - 0.2958279

RTL
2021-09-16 16:57:19.742 D/imageRect:  0.010981758 - 0.09856376 - 0.048717607 - 0.17073357
2021-09-16 16:57:19.743 D/imageRect:  0.036925156 - 0.17554489 - 0.1006044 - 0.2958279
2021-09-16 16:57:19.743 D/imageRect:  0.08645345 - 0.1081864 - 0.15484968 - 0.22846942
2021-09-16 16:57:19.744 D/imageRect:  0.1477742 - 0.17554489 - 0.19258553 - 0.2717713
2021-09-16 16:57:19.744 D/imageRect:  0.19022705 - 0.06007319 - 0.5723025 - 0.81545055
2021-09-16 16:57:19.745 D/imageRect:  0.2491893 - 0.3679977 - 0.9968308 - 0.9934694
2021-09-16 16:57:19.749 D/imageRect:  0.66428363 - 0.05045055 - 0.81522703 - 0.35356376
2021-09-16 16:57:19.758 D/imageRect:  0.824661 - 0.021582626 - 0.94022703 - 0.25252602
2021-09-16 16:57:19.763 D/imageRect:  0.94022703 - 0.2236581 - 0.9779629 - 0.2958279

@veena14cs
Copy link
Contributor

Can we force that particular layout to be LTR in RTL device? As it is a image and doesn't change for RTL. I have created PR PTAL @anandwana001 @rt4914 and @BenHenning.

@anandwana001 anandwana001 removed their assignment Sep 27, 2021
anandwana001 pushed a commit that referenced this issue Sep 27, 2021
* Update selection_interaction_item.xml

* Update selection_interaction_item.xml

* Update return_to_topic_button_item.xml

* Update return_to_topic_button_item.xml

* Update image_region_selection_interaction_item.xml

* Update image_region_selection_interaction_item.xml

* Update image_region_selection_interaction_item.xml

* Update image_region_selection_interaction_item.xml

* Update image_region_selection_interaction_item.xml

* fixed image region selection

* Add tests

* Update ImageRegionSelectionInteractionViewTest.kt

* Update ImageRegionSelectionInteractionViewTest.kt

* Update ImageRegionSelectionInteractionViewTest.kt

* Update ImageRegionSelectionInteractionViewTest.kt

* Update app/src/main/java/org/oppia/android/app/utility/ClickableAreasImage.kt

Co-authored-by: Ben Henning <[email protected]>

* Update ClickableAreasImage.kt

* Update ClickableAreasImage.kt

* Remove ignore and add RunOn Expresso platform

* Update ImageRegionSelectionInteractionViewTest.kt

* Add oppiaTest rule

* Update ImageRegionSelectionInteractionViewTest.kt

Co-authored-by: Ben Henning <[email protected]>
@BenHenning
Copy link
Sponsor Member Author

For searching context, this issue was found in 0.6-alpha (MR3).

@BenHenning BenHenning added the Z-ibt Temporary label for Ben to keep track of issues he's triaged. label Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-ibt Temporary label for Ben to keep track of issues he's triaged.
Development

Successfully merging a pull request may close this issue.

3 participants