Skip to content

Fix theme crash when showing permission disclosures - #72

Merged
MartinaeyNL merged 1 commit into
mainfrom
fix/permission-disclosure-theme-crash
Aug 5, 2026
Merged

Fix theme crash when showing permission disclosures#72
MartinaeyNL merged 1 commit into
mainfrom
fix/permission-disclosure-theme-crash

Conversation

@Miggets7

@Miggets7 Miggets7 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #71.

#66 introduced PermissionDisclosures, which builds an androidx.appcompat.app.AlertDialog directly on the host activity. ORLib forces no theme and OrMainActivity is a plain Activity, so the effective theme comes from the consuming app. Consoles with a non-AppCompat theme crash with java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. on every disclosure path. GenericApp in this repo uses OpenRemoteTheme (AppCompat descendant), which is why the regression was not visible here.

Fix: resolve alertDialogTheme on the activity theme; when missing, wrap the activity in a ContextThemeWrapper with Theme_AppCompat_DayNight_Dialog_Alert. AppCompat-themed apps see no visual change.

Verification: new instrumented regression test PermissionDisclosuresTest with 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 AppCompat AlertDialog on the activity the same way. Same latent crash for non-AppCompat consumers, pre-existing before 1.5.1.

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
MartinaeyNL merged commit 467cdff into main Aug 5, 2026
1 check passed
@MartinaeyNL
MartinaeyNL deleted the fix/permission-disclosure-theme-crash branch August 5, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fatal crash when initializing ESPProvisionProvider without bluetooth permission

2 participants