-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Improved handling errors when starting new forms or editing existing ones #5542
Conversation
1c91175
to
f99be90
Compare
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.
Initially, I wanted to disable editing finalized and sent forms as described in the issue but I ended up with a lot of failing tests and the UI where those finalized forms were still in the list of forms to edit but couldn't be edited. We have a separate issue for that: #5418
Agreed, this makes sense as a refactor before working on #5419. As you point out, I think it makes sense to work on #5418 before that as well, and the issues are prioritized like that in the backlog.
FormEntryActivity is an exported activity and can be started from an external app by its name (see the tester app)
FormEntryActivity
itself isn't exported as far as I can see - there's an activity-alias
that is. I think this means that you should be able to change the targetActivity
of the alias to FormURIActivity
right?
This would cause an infinite loop 😄 Generally, I don't know why that alas is there at all... it looks like:
so |
Oh no! I thought that aliases only worked outside of the app, so that wouldn't happen. I agree that just renaming |
Done. Thanks to that I was able to remove all the checks (if data is valid) from I think the next step to make would be to pass the Form/Instance object to |
Maybe just passing in the Form or Instance DB ID would be best? That way can avoid serializing the object or risking anything big getting written out to disk with the rest of the intent. It'd be great to avoid issues for this kind of thing because it's always hard to work out prioritization for refactors vs features. Just go ahead and make the change as a follow-up PR, or include here if you think it's small? |
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'm really liking this change so far. Feels much cleaner. I've still got to have a good look through FormUriActivityTest
, but I thought it'd make sense to get these thoughts in early as I think it'll be ready for QA after these few little tweaks.
collect_app/src/androidTest/java/org/odk/collect/android/support/rules/BlankFormTestRule.kt
Outdated
Show resolved
Hide resolved
..._app/src/androidTest/java/org/odk/collect/android/support/rules/FormEntryActivityTestRule.kt
Outdated
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/external/FormUriActivity.kt
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/external/FormUriActivity.kt
Outdated
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/formmanagement/FormNavigator.kt
Outdated
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/formmanagement/FormNavigator.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.
I still have to review the one test file (and I probably won't get to it until next week), but this is ready for QA any changes there shouldn't affect behaviour.
All requested changes made, but still more to review.
Tested with Success! Verified on device with Android 10 Verified cases:
Since most of the tests rely on ODK Collect Intents Testers app which doesn’t work on devices with Android 11 and above, testing was conducted on Android 10. On Android 13 there were only regression checks in the Collect app. Because of that we don’t remove the label needs testing. If you decide that testing with ODK Collect Intents Testers app only on Android 10 is enough, please remove the label. |
After the update of ODK Collect Intents Testers app I reproduced the errors/cases again on Android 10 and everything works well. |
Tested with Success! Verified on device with Android 13
|
My bad on closing! Pro-tip: Android Studio's GitHub plugin has a button that says "Close Pull Request" - it doesn't close the window with the PR info. |
@grzesiek2010 looks like this needs a final conflict resolve before merging |
… that to FormUriActivity
…rm filling directly without using FormUriActivity
Work towards #5419
What has been done to verify that this works as intended?
I've tested the changes manually with the tester app: https://github.com/grzesiek2010/collectTester and added automated tests.
Why is this the best possible solution? Were any other approaches considered?
The goal of this issue was to block editing of finalized or sent forms via Content Provider. I've handled that in FormUriActivity.
As we discussed earlier
FormUriActivity
should be like a gate to form filling where we check if it makes sense to start the process at all (data validation). I've taken the opportunity and improved that class by validating other cases as well so that now the class contains a series of methods asserting that everything is ok and form filling can be started.I've also made sure
FormEntryActivity
is not used directly in our app but only byFormUriActivity
after validating all cases: 29ebf51I could remove some duplicate validations fromFormEntryActivity
now as it is checked inFormUriActivity
but there is one problem...FormEntryActivity
is an exported activity and can be started from an external app by its name (see the tester app). It shouldn't work like that because now even if we block editing of finalized or sent forms via Content Provider it is still possible usingFormEntryActivity
directly. I was a little bit afraid of changing this state and making the activity not exported because maybe there are some projects that rely on it so I decided to leave it as is for now and add analytics: a120365Initially, I wanted to disable editing finalized and sent forms as described in the issue but I ended up with a lot of failing tests and the UI where those finalized forms were still in the list of forms to edit but couldn't be edited. We have a separate issue for that: #5418
Since the pr contains a lot of improvements in
FormUriActivity
as described above I think it would be good to test it and merge and disable editing finalized forms in a separate one. That's why in the last commit I brought back the original behavior (editing finalized forms).How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Please test editing forms using the tester app: https://github.com/grzesiek2010/collectTester. I've implemented some refactoring so it probably would make sense to test starting forms using that app (including some weird scenarios when forms should not be started see what cases should block starting a form
FormUriActivityTest
)Do we need any specific form for testing your changes? If so, please attach one.
No.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
./gradlew checkAll
and confirmed all checks still pass OR confirm CircleCI build passes and run./gradlew connectedDebugAndroidTest
locally.