Fix theme crash when showing permission disclosures - #72
Merged
Conversation
PermissionDisclosures built an AppCompat AlertDialog directly on the host activity, crashing with "You need to use a Theme.AppCompat theme (or descendant) with this activity" in console apps whose activity theme is not an AppCompat descendant. Wrap the activity in an AppCompat dialog theme when its own theme cannot resolve alertDialogTheme. Adds instrumented regression tests covering AppCompat and non-AppCompat themed activities. Closes #71
MartinaeyNL
approved these changes
Aug 5, 2026
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.
Fixes #71.
#66 introduced
PermissionDisclosures, which builds anandroidx.appcompat.app.AlertDialogdirectly on the host activity. ORLib forces no theme andOrMainActivityis a plainActivity, so the effective theme comes from the consuming app. Consoles with a non-AppCompat theme crash withjava.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.on every disclosure path. GenericApp in this repo usesOpenRemoteTheme(AppCompat descendant), which is why the regression was not visible here.Fix: resolve
alertDialogThemeon the activity theme; when missing, wrap the activity in aContextThemeWrapperwithTheme_AppCompat_DayNight_Dialog_Alert. AppCompat-themed apps see no visual change.Verification: new instrumented regression test
PermissionDisclosuresTestwith a platform-themed and an AppCompat-themed activity. Without the fix, the platform-theme test reproduces the exact stack trace from #71; with the fix both pass (Pixel 9a emulator, Android 16). This adds androidx.test/espresso dependencies to ORLib, which had a test runner configured but no test sources.Follow-up, not in this PR:
OrMainActivity.kt:769("notifications disabled" alert) builds an AppCompatAlertDialogon the activity the same way. Same latent crash for non-AppCompat consumers, pre-existing before 1.5.1.