Skip to content

fix: prevent Expanded Dark Theme inversion on scanner activity#56

Merged
OS-pedrogustavobilro merged 6 commits into
mainfrom
fix/RMET-5280/expanded-dark-theme
Jun 26, 2026
Merged

fix: prevent Expanded Dark Theme inversion on scanner activity#56
OS-pedrogustavobilro merged 6 commits into
mainfrom
fix/RMET-5280/expanded-dark-theme

Conversation

@OS-pedrogustavobilro

@OS-pedrogustavobilro OS-pedrogustavobilro commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds a AppCompat DayNight theme to OSBARCScannerActivity so Android does not treat it as a legacy light-themed activity and invert its colors when Expanded Dark Theme is enabled.

In this PR I also do a few housekeeping changes like updating PR template and commenting SonarCloud template because it was failing CI and we're not really using it atm.

Consumer Plugins note

Because this library is consumed as @aar in cordova plugin, will need to explicitly add google material dependency there otherwise the app won't build because it won't find Material3 theme.

Same thing for capacitor plugin

Context

Expanded Dark Theme is an accessibility feature added in Android 16.1, that when enabled, was causing the scanning screen to have a white tint, because (without this fix) it was assuming the screen was not in dark mode, therefore (wrongfully) inverting the colors.

Internal jira Reference: https://outsystemsrd.atlassian.net/browse/RMET-5280

Type of changes

  • Fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Refactor (cosmetic changes)
  • Breaking change (change that would cause existing functionality to not work as expected)

Tests

I tested OutSystems Sample apps (O11 with Cordova and ODC with Capacitor). If you'd like to test yourself, refer to the following apk files in this drive folder ("before" for without this PR, "after" for with this PR): https://drive.google.com/drive/folders/1PeI7udQya5Ad4cMBTNXP0jPfUgOpenuF?usp=sharing

Screenshots (if appropriate)

The following are screenshots on a Pixel device with Android 17 and Expanded Dark Theme enabled in device settings.

Before PR After PR
pixel_android17_before pixel_android17_after

Checklist

  • Code follows code style of this project
  • CHANGELOG.md file is correctly updated
  • Changes require an update to the documentation
    • Documentation has been updated accordingly

Adds an AppCompat DayNight theme to `OSBARCScannerActivity` so Android does not treat it as a legacy light-themed app and invert its colors when Expanded Dark Theme is enabled.

References: https://outsystemsrd.atlassian.net/browse/RMET-5280
Might be 2.1.0 instead if we bundle with #55; depends on merge order / time.
Not being used these days, might as well comment to see if CI passes
@OS-pedrogustavobilro OS-pedrogustavobilro marked this pull request as ready for review June 25, 2026 17:02
@OS-pedrogustavobilro OS-pedrogustavobilro requested a review from a team as a code owner June 25, 2026 17:02
Comment thread .github/workflows/run-unit-tests.yml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.BarcodeScannerActivity"
parent="Theme.AppCompat.DayNight.NoActionBar" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Random question, does it matter that this theme is Theme.AppCompat.* but the activity is a ComponentActivity (not AppCompatActivity)? Not sure if it's an issue or just a nit, but I think there's also a Theme.Material3.DayNight.NoActionBar that might be a better fit for a Compose activity, right? Worth checking?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For your first question, doesn't matter that much no, what would happen is that theme brings up additional properties that won't end up being used by this activity because it's not using AppCompat components

For your second question, I didn't use Theme.Material3.DayNight.NoActionBar because it was failing builds for OutSystems, but now that I see it, it's because https://github.com/OutSystems/cordova-outsystems-barcode/blob/main/src/android/com/outsystems/plugins/barcode/build.gradle#L27 has the @aar which means no transitive dependencies come, and so the build failed because it was missing a material library dependency. After adding that, it works fine.

However, when I create an empty compose app, it actually comes with android:Theme.Material.Light.NoActionBar. I thought that would work, but apparently not, still getting color inversion with that theme - This might be due to the native theme configurations of an OutSystems application vs that empty Compose one, didn't exactly figure it out.

But anywho, I'm going with that Theme.Material3.DayNight.NoActionBar that seems to work. Thanks for bringing it up!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: Will need to do similar change for capacitor plugin, but it's fine

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks for the clarification 👍

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually @OS-ruimoreiramendes I changed my mind 😆 after building an app with and without the google material dependency, it increases the full apk size (debug) by 15 MB and the download size (debug) 1.5 MB. While maybe release builds with R8 would shrink that difference, I don't think it's worth the added size for what is in truth, more of a cosmetic change - So I'm changing back to AppCompat 😅

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough 😅 15 MB is way too much for a cosmetic win.

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.

2 participants