-
Notifications
You must be signed in to change notification settings - Fork 521
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
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. |
…into handle-configuration-change-using-onSavedInstance
…into handle-configuration-change-using-onSavedInstance
app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
app/src/main/java/org/oppia/android/app/player/state/StateFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/player/state/StateFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt
Outdated
Show resolved
Hide resolved
...org/oppia/android/app/player/state/itemviewmodel/ImageRegionSelectionInteractionViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt
Outdated
Show resolved
Hide resolved
Resolved all my open conversations. |
@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. |
@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. |
You can find more info about problem I am facing to reset animation in selection interaction from this debugging doc, thanks. |
There was a problem hiding this 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.
import kotlinx.android.synthetic.main.item_selection_interaction_items.view.* | ||
import kotlinx.android.synthetic.main.multiple_choice_interaction_items.view.* |
There was a problem hiding this comment.
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.
@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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
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. |
@vrajdesai78 let’s skip the animation. For the default region, how do you propose we pipe the necessary information? |
@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. |
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. |
@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? |
Inside clickable for default region we won't have any parameters like for labelled region we have label and content description |
Line 60 in 5e64fae
|
@BenHenning added a parameter to store coordinates according to your suggestion. Can you PTAL. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
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. |
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
Demo Video
ScreenRotation.mp4
Passing esspresso tests