Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add AndroidWindowOptOutEdgeToEdgeEnforcement preference & theme flag #1779

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

erisu
Copy link
Member

@erisu erisu commented Feb 14, 2025

Motivation and Context

  • Disable the Edge-to-Edge setting that SDK 35 enabled by default.
  • Allow users to opt-in to the Edge-to-Edge feature with a flag.

In the next Cordova-Android release, we will temporarily disable the Edge-to-Edge feature to maintain the same behavior that existed previously. The new feature appears to have issues with safe-area-*.

When setting viewport-fit to auto or contain, the content will render behind the safe-area which is believed to be an unintended behavior. iOS for example will automatically render the content below the statusbar.

Description

  • Added theme flag android:windowOptOutEdgeToEdgeEnforcement and default to true
  • Added preference flag AndroidWindowOptOutEdgeToEdgeEnforcement to allow changing of the theme flag

Testing

  • build app and test flag

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@dpogue
Copy link
Member

dpogue commented Feb 14, 2025

Note that because Edge-To-Edge is disabled by default, viewport-fit=cover also won't do anything.

You can opt-in to working viewport-fit=cover with safe-area-inset-top values by setting the AndroidWindowOptOutEdgeToEdgeEnforcement preference to false in config.xml.
(Further note: safe-area-inset-bottom is never correct on Android, so be aware of that if you are wanting to opt-in)

@codecov-commenter
Copy link

codecov-commenter commented Feb 14, 2025

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 72.43%. Comparing base (eb0f002) to head (18b0e61).

Files with missing lines Patch % Lines
lib/prepare.js 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1779      +/-   ##
==========================================
- Coverage   72.50%   72.43%   -0.08%     
==========================================
  Files          23       23              
  Lines        1837     1839       +2     
==========================================
  Hits         1332     1332              
- Misses        505      507       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@erisu erisu added this to the 14.0.0 milestone Feb 14, 2025
@dpogue
Copy link
Member

dpogue commented Feb 19, 2025

Just a note that the windowOptOutEdgeToEdgeEnforcement option is removed in Android 16 (as per https://android-developers.googleblog.com/2025/02/second-beta-android16.html)

Edge to edge opt-out going away

Android 15 enforced edge-to-edge for apps targeting Android 15 (SDK 35), but your app could opt-out by setting R.attr#windowOptOutEdgeToEdgeEnforcement to true. Once your app targets Android 16 (Baklava), R.attr#windowOptOutEdgeToEdgeEnforcement is deprecated and disabled and your app cannot opt-out of going edge-to-edge. To be compatible with Android 16 Beta 2, ensure your app supports edge-to-edge and remove any use of R.attr#windowOptOutEdgeToEdgeEnforcement. To support edge-to-edge, see the Compose and Views guidance. Please let us know about concerns in our tracker on the feedback page.

@erisu
Copy link
Member Author

erisu commented Feb 20, 2025

Last call for reviews before merging in.

@dpogue
Copy link
Member

dpogue commented Feb 20, 2025

I do sortof question if it's worth merging this knowing that it's going to be deprecated immediately in the next release.

Unfortunately there aren't really any alternatives at the moment, so it's probably better to have something than nothing :\

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.

3 participants