Handle edge-to-edge when it's not enabled by gradle property#56055
Handle edge-to-edge when it's not enabled by gradle property#56055zoontek wants to merge 13 commits intofacebook:mainfrom
Conversation
27a6185 to
6c7846d
Compare
|
@alanleedev has imported this pull request. If you are a Meta employee, you can view this in D100437440. |
deafc34 to
01d0e4c
Compare
| val attributes = intArrayOf(AndroidVersion.ATTR_WINDOW_OPT_OUT_EDGE_TO_EDGE_ENFORCEMENT) | ||
| val typedArray = context.theme.obtainStyledAttributes(attributes) |
There was a problem hiding this comment.
This could be an issue when the context passed in is Application context and windowOptOutEdgeToEdgeEnforcement is set on the Activity. We may incorrectly decide there is no opt-out attribute set.
There was a problem hiding this comment.
Actually, I think you missed adding initEdgeToEdge() in ReactActivityDelegate. If this is fixed then initEdgeToEdge() is called first from ReactNativeApplicationEntryPoint (with the Application context) and then again from ReactActivityDelegate (with the Activity context). There may be some edge cases but it may still work mostly.
There was a problem hiding this comment.
@alanleedev Fixed in acacab6. It even allows us to remove the public attribute on initEdgeToEdge
There was a problem hiding this comment.
@alanleedev @cortinico This actually even allows us to remove isDeviceRunningEdgeToEdge, making the PR changes minimal.
|
@alanleedev this can be re-imported imho |
|
This pull request was successfully merged by @zoontek in c2280e3 When will my fix make it into a release? | How to file a pick request? |
# Conflicts: # packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/WindowUtil.kt
Summary:
On Android 15 (API 35), edge-to-edge is enforced by default unless the app explicitly opts out via
windowOptOutEdgeToEdgeEnforcement. On Android 16+, it's always enforced regardless.Previously, edge-to-edge behavior was only driven by the
edgeToEdgeEnabledgradle property, meaning apps on Android 15+ could be in edge-to-edge mode without React Native being aware of it, leading to incorrect insets / layout behavior.This PR introduces
isEdgeToEdge, a computed value that accounts for the OS-level enforcement in addition to the gradle flag, and replaces most usages ofisEdgeToEdgeFeatureFlagOnwith it. A newinitEdgeToEdge(context, flag)function replacessetEdgeToEdgeFeatureFlagOn()and reads the theme attribute to detect opt-out on API 35.Changelog:
[ANDROID] [FIXED] - Handle edge-to-edge when it's not enabled by the
edgeToEdgeEnabledgradle property but enforced by the OS (Android 15+)Test Plan:
edgeToEdgeEnabled = true:isEdgeToEdgeshould betrue(unless opted out via theme attribute).isEdgeToEdgeshould always betrue.isEdgeToEdgeshould befalse.edgeToEdgeEnabled = true: behavior unchanged,isEdgeToEdgeistrueon all API levels.