Fix WebView workaround causing Activity to be shown with incorrect theme#5844
Merged
seadowg merged 1 commit intogetodk:v2023.3.xfrom Nov 23, 2023
Merged
Fix WebView workaround causing Activity to be shown with incorrect theme#5844seadowg merged 1 commit intogetodk:v2023.3.xfrom
WebView workaround causing Activity to be shown with incorrect theme#5844seadowg merged 1 commit intogetodk:v2023.3.xfrom
Conversation
WebView workaround causing Activity to be shown with incorrect theme
...oidshared/src/main/java/org/odk/collect/androidshared/ui/FixMismatchThemeProblemsActivity.kt
Show resolved
Hide resolved
grzesiek2010
requested changes
Nov 22, 2023
...oidshared/src/main/java/org/odk/collect/androidshared/ui/FixMismatchThemeProblemsActivity.kt
Outdated
Show resolved
Hide resolved
| * | ||
| * See [this issue](https://issuetracker.google.com/issues/37124582) for more details. | ||
| */ | ||
| class FixMismatchThemeProblemsActivity : AppCompatActivity() { |
Member
There was a problem hiding this comment.
Does it really need to be in an activity? Maybe it could be just a method in ApplicationInitializer instead?
Member
Author
There was a problem hiding this comment.
Ah great point! I'd assumed that we needed an Activity to "sacrifice", but it looks like if I stick the WebView initialisation in ApplicationInitializer it does fix the problems. Will rework this.
grzesiek2010
approved these changes
Nov 23, 2023
|
Tested with Success! Verified on device with Android 13 Verified cases:
|
|
Tested with Success! Verified on device with Android 10 |
seadowg
added a commit
to seadowg/collect
that referenced
this pull request
Nov 30, 2023
Fix `WebView` workaround causing Activity to be shown with incorrect theme
seadowg
added a commit
to seadowg/collect
that referenced
this pull request
Dec 7, 2023
Fix `WebView` workaround causing Activity to be shown with incorrect theme
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes an issue where form entry starts with the dark/light theme when the other is selected. To reproduce using v2023.3.0:
You'll see the first screen loads as the system theme in some parts, and the project theme in others.
Why is this the best possible solution? Were any other approaches considered?
We were previously avoiding a very similar issue from occurring if the image select widget was in a form: once the widget was viewed, moving backwards or forwards in a form would cause some parts of the view to use the system theme rather than the project one. See this Android issue for more details.
The solution here is mostly described in my comment in
FixMismatchThemeProblemsActivity: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?
Should just fix the issue as described. It would be good to try and mess around with different projects using different themes to see if there's still a way to reproduce.
The problems the
WebViewwas actually dealing with was that if you opened a form with a select one from image widget, moved to it and then moved to another widget (backwards or forwards), parts of the UI would use the system theme rather than the app one. You can see conversations about that here.Before submitting this PR, please make sure you have:
./gradlew checkAlland confirmed all checks still pass OR confirm CircleCI build passes and run./gradlew connectedDebugAndroidTestlocally.