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

Fixes #4470, #4471, #4472, #4473, #4474, #4708: Handle configuration change using on saved instance #4668

Conversation

vrajdesai78
Copy link
Contributor

@vrajdesai78 vrajdesai78 commented Oct 19, 2022

Explanation

Fixes #4470: State of input interactions is retained on configuration change using onSavedInstance.
Fixes #4471: Retain state for Text based interactions
Fixes #4472: Retain state for ImageRegion
Fixes #4473: Retain state for DragAndDrop
Fixes #4474: Retain State for SelectionInteraction
Fixes #4708: Fixed issue of returning null view in onSubmit time error

Essential Checklist

  • The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).

Demo Video

ScreenRotation.mp4

Passing esspresso tests

Screenshot from 2022-11-07 00-50-29
Screenshot from 2022-11-07 00-50-00
Screenshot from 2022-11-07 00-34-11
Screenshot from 2022-11-07 00-33-47
Screenshot from 2022-11-07 00-31-04
Screenshot from 2022-11-07 00-30-08
Screenshot from 2022-11-07 00-29-21
Screenshot from 2022-11-07 00-20-01
Screenshot from 2022-11-13 08-30-37
Screenshot from 2022-11-13 08-29-58
Screenshot from 2022-11-13 08-27-40
Screenshot from 2022-11-13 07-26-20
Screenshot from 2022-11-13 08-05-20
Screenshot from 2022-11-13 08-04-47
Screenshot from 2022-11-13 08-03-54
Screenshot from 2022-11-13 08-01-50
Screenshot from 2022-11-13 08-02-39

@BenHenning BenHenning self-assigned this Oct 19, 2022
@BenHenning
Copy link
Member

Since we discussed how to proceed here, I don't think I need to take any further review action at this time. Assigning back to you @vrajdesai78.

@BenHenning BenHenning assigned vrajdesai78 and unassigned BenHenning Oct 21, 2022
@vrajdesai78 vrajdesai78 marked this pull request as ready for review October 21, 2022 18:12
@vrajdesai78 vrajdesai78 removed their assignment Oct 21, 2022
@BenHenning BenHenning assigned vrajdesai78 and unassigned BenHenning Oct 22, 2022
@BenHenning BenHenning removed their assignment Oct 22, 2022
Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vrajdesai78. Took a mostly fully pass (didn't look at questions or tests yet since both are probably gonna change yet).

Please also make sure that all current interactions are correctly tested such that we can demonstrate that rotation logic does work upon configuration change.

@BenHenning BenHenning removed their assignment Oct 25, 2022
@rt4914 rt4914 removed their assignment Nov 13, 2022
@rt4914
Copy link
Contributor

rt4914 commented Nov 13, 2022

Resolved all my open conversations.

@vrajdesai78
Copy link
Contributor Author

When testing this locally @vrajdesai78 I noticed two things:

  1. For multiple choice & item selection interactions, rotating causes the bullet items/checkboxes to animate slightly (as if they were just clicked). This seems wrong since the UI should be retaining the exact state, not showing as though the items were recently clicked.
  2. The image region selection interaction isn't correctly retaining the default selection (i.e. when selecting a region that isn't one of the known regions), and confusingly reverts back to the last selected region after 2 rotations. We should be also retaining the default region location.

Please address both of these, and include a test for the default region one.

@BenHenning I have tried to remove animation in selection interaction view by calling jumpDrawablesToCurrentState(), but the issue is with my current implementation the animation got removed even after the screen rotates means once previously selected item is selected then also if user selects any other item the animation is removed. Do you have any suggestion how can I fix this issue, currently I am calling jumpDrawablesToCurrentState() on setOnChangedListener, is there any other way to do this.

Also, to retain state for default image region, do you have any suggestions how can I retain it's state.

@seanlip
Copy link
Member

seanlip commented Nov 13, 2022

@vrajdesai78 Just a note, this discussion will likely be more efficient if you can explain what approaches you have tried and have considered for e.g. image region.

For the animation it would help to see a debugging doc with your understanding of the problem and the current flows.

@vrajdesai78
Copy link
Contributor Author

You can find more info about problem I am facing to reset animation in selection interaction from this debugging doc, thanks.

Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some follow-up comments, and one on the doc @vrajdesai78.

For the checkbox, does setChecked() cause the animation to trigger? If so, we may need to look into using view attributes and/or a custom view to initialize the checkbox to off. That being said, if we can't find an obvious solution to this, it might be fine for us to live with (but we should file an issue to track it).

Regarding image region selection, what have you tried? You'll need to look into how the default region is represented and make sure that we're able to re-add the default view upon reinitializing the view model.

Comment on lines 10 to 11
import kotlinx.android.synthetic.main.item_selection_interaction_items.view.*
import kotlinx.android.synthetic.main.multiple_choice_interaction_items.view.*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid using synthetic imports--these are deprecated.

Comment on lines 31 to 36
@field:[Inject ExplorationHtmlParserEntityType] lateinit var entityType: String
@field:[Inject DefaultResourceBucketName] lateinit var resourceBucketName: String
@field:[Inject ExplorationHtmlParserEntityType]
lateinit var entityType: String
@field:[Inject DefaultResourceBucketName]
lateinit var resourceBucketName: String
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert style-only changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted back

@@ -77,6 +77,7 @@ class SelectionInteractionViewModel private constructor(
rawUserAnswer.itemSelection.selectedIndexesList.forEach { index ->
selectedItems += index
updateIsAnswerAvailable()
choiceItems[index].disableAnimation = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to keep the animation disabled with additional user interactions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted back changes as this approach won't work

@BenHenning BenHenning removed their assignment Nov 13, 2022
@vrajdesai78
Copy link
Contributor Author

Hey @BenHenning I have checked how we actually get the unlabeled region, so we use have onClickListener inside an init method of ClickableAreasImage.kt. To retain the state of default region I need to access it's exact coordinates inside ImageRegionSelectionViewModel because other than it's coordinates there is no other way we can access unlabelled region.

My query is how can we get this exact coordinates of selected region inside an ImageRegionSelectionViewModel, for labelled region we simply retrieve it's coordinates from selectableRegions, but for unlabelled region we can't retrieve it's coordinates from selectable regions as it doesn't have label.

For selection Interaction I have tried to use setChecked inside a custom view, for that I send selected indices from viewModel to custom view and inside that view I have tried to use setChecked on selected indices, but the view is returning null as I won't able to directly access particular checkbox to mark it as checked, also here I think that even if I am able check checkbox still it will show animation as by default checkboxes have animation.

@BenHenning
Copy link
Member

@vrajdesai78 let’s skip the animation. For the default region, how do you propose we pipe the necessary information?

@vrajdesai78
Copy link
Contributor Author

vrajdesai78 commented Nov 14, 2022

@BenHenning can we remove the support for default region for normal users like we do for screen reader users as I don't think that it will create any problem in user experience as selecting unlabelled region won't help user to learn anything, just saying if we remove it then we don't need to handle the case to retain the state of unlabelled region. Also, mostly it is expected that user clicks on labelled region only as the interaction itself is to click on image regions.

@vrajdesai78
Copy link
Contributor Author

vrajdesai78 commented Nov 14, 2022

@vrajdesai78 let’s skip the animation. For the default region, how do you propose we pipe the necessary information?

We need to get the exact coordinates which user has clicked inside an ImageRegionSelectionViewModel from that we can pass it inside lastSelectedRegion. I want to know how we can actually get that coordinates or unlabelled selected region inside a viewModel.

@BenHenning
Copy link
Member

@vrajdesai78 this is a problem for sighted users; config changes affect all users, not just screenreader users.

For the coordinates, the default region is known by the clickable image utility. Can we derive the coordinates from there?

@vrajdesai78
Copy link
Contributor Author

Inside clickable for default region we won't have any parameters like for labelled region we have label and content description

@BenHenning
Copy link
Member

couldn’t we just pass along the coordinates? I understand that we can’t pipe the necessary data today, but we need to change it so that we can.

@vrajdesai78
Copy link
Contributor Author

@BenHenning added a parameter to store coordinates according to your suggestion. Can you PTAL.

Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is on the right track @vrajdesai78 but it’s not a complete solution yet. You need to reconstitute the default region from the coordinates and make sure the coordinates are included in the raw user answer.

@@ -8,6 +10,10 @@ interface OnClickableAreaClickedListener {
* For an specified region it will be called with [NamedRegionClickedEvent] with region name.
* For an unspecified region it will be called with [DefaultRegionClickedEvent].
*
* @param coordinates the coordinates of unlabelled region
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn’t this be the coordinates of the region? Why is it specifically the unlabeled region?

@BenHenning BenHenning removed their assignment Nov 19, 2022
@oppiabot
Copy link

oppiabot bot commented Nov 26, 2022

Hi @vrajdesai78, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Nov 26, 2022
@oppiabot oppiabot bot closed this Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Corresponds to items that haven't seen a recent update and may be automatically closed.
Projects
None yet
4 participants