Guest Registration - Third Fragment - Need to Save User Multi-Data Selections on Activity State Orientation Change / Recreation
License and Copyright Notice
By submitting this issue or commenting on this issue, or contributing any content to this issue, you certify under the Developer Certificate of Origin that the content you post may be licensed under GPLv3 (for code) or CC-BY-SA 4.0 International (for non-code content).
Summary
See:
GuestDatabaseRegistrationActivity.java
ThirdFormFragment.java
fragment_guest_database_registration_third_form.xml
When filling out Guest Registration, on the Third Form (asking for dietary needs / health status / etc), elements asking for "Select all that Apply" (e.g. MultiSelectSpinners) will not preserve user selections on activity state / orientation changes.
Steps to reproduce
(How one can reproduce the issue - this is very important - be as specific as possible, what did you click, type, etc.)
- Open the application.
- Select "Guest Registration" from the Home page.
- Fill out the first form.
- Proceed to the next form via the "Next" button.
- Fill out the necessary information for the second form.
- Proceed to the next form via the "Next" button.
- In elements prompting "Select all that apply", select one or more available settings that show in the pop-up when one of these elements is selected.
- Rotate the device and wait for the application to rotate. If it does not rotate, ensure that device rotation is enabled.
- You will see that the elements that have been reset from the chosen selections back to "Select all that apply," invalidating the user's input and demanding resubmission.
What is the current bug behavior?
You will see that the user-input data selections in the MultiSelectSpinners have been reset from the chosen selections back to "Select all that apply," invalidating the user's input and demanding resubmission.
What is the expected correct behavior?
You should see that the user-input data selections in the MultiSelectSpinners have preserved the chosen selections on orientation change or other activity state changes.
Relevant logs and/or screenshots
(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code, as it's very hard to read otherwise.)
Possible fixes
See:
GuestDatabaseRegistrationActivity.java
ThirdFormFragment.java
fragment_guest_database_registration_third_form.xml
Possible solutions: I believe the problem lies in ThirdFormFragment.java and the elements it references in fragment_guest_database_registration_third_form.xml. The user-input values are saved via the SharedPreferences class, but for some reason those used in MutliSelectSpinners are defaulting to having nothing selected. I would start there. If SharedPreferences does not work directly, perhaps a more manual method for saving the data would work?
See:
ThirdFormFragment.java (Not exhaustive list)
Line 96
Lines 101 - 104
Lines 127 - 135
Lines 144 - 147
Lines 279 - 284
Lines 289 - 295
See:
https://developer.android.com/training/data-storage/shared-preferences
https://developer.android.com/reference/android/content/SharedPreferences
Labels
(We have not finalized our list of labels, for now, include the labels you would like to include as a comment.