Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content

Conversation

@triniwiz
Copy link
Member

@triniwiz triniwiz commented Jan 29, 2026

Improvements to Android edge-to-edge support and overflow handling.

  • Refactored the enableEdgeToEdge API in native-helper-for-android.ts to accept either a Window or options object, and added new utility functions getIgnoreEdgeToEdgeOnOlderDevices and setIgnoreEdgeToEdgeOnOlderDevices for more granular control. [1] [2] [3] [4]
  • Updated Android dialog initialization to enable edge-to-edge mode for dialog windows, ensuring consistent UI appearance. [1] [2]

Overflow Handling Improvements:

  • Expanded the AndroidOverflow type to support AndroidOverflowMultiple in addition to existing options, allowing for more flexible overflow edge configurations.
  • Refactored overflow edge handling in LayoutBase.java to improve inset management and listener setup, including new buffer management methods and more robust handling of ignored edges. [1] [2]

Android SDK and Dependency Updates:

  • Updated Android SDK versions to 36 and bumped dependencies for androidx.fragment, androidx.activity, and added androidx.core for improved compatibility and access to new features. [1] [2] [3] [4] [5]

@nx-cloud
Copy link

nx-cloud bot commented Jan 29, 2026

View your CI Pipeline Execution ↗ for commit 9fe40a4

Command Status Duration Result
nx test apps-automated -c=ios ✅ Succeeded 2m 40s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-30 17:53:58 UTC

@triniwiz triniwiz marked this pull request as ready for review January 29, 2026 22:53
@NathanWalker NathanWalker requested a review from Copilot January 30, 2026 00:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves edge-to-edge window handling on Android by refactoring the insets management logic and adding support for enabling edge-to-edge for dialog windows. It also updates the Android SDK from API 35 to API 36 and updates several AndroidX dependencies.

Changes:

  • Added new enableEdgeToEdge overloads that accept a Window parameter for enabling edge-to-edge on dialogs
  • Refactored window insets handling in LayoutBase to simplify overflow edge logic
  • Added ignoreEdgeToEdgeOnOlderDevices flag to optionally disable edge-to-edge on older Android versions
  • Updated Android SDK to API 36 and AndroidX dependencies to latest versions

Reviewed changes

Copilot reviewed 9 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/Utils.java Added Window-based edge-to-edge overloads and version check flag
packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/LayoutBase.java Refactored window insets handling logic for cleaner overflow edge management
packages/ui-mobile-base/android/widgets/build.gradle Updated SDK to API 36 and AndroidX dependencies to latest versions
packages/ui-mobile-base/android/widgetdemo/src/main/java/org/nativescript/widgetsdemo/MainActivity.kt Added dialog fragment test case demonstrating Window-based edge-to-edge
packages/ui-mobile-base/android/widgetdemo/build.gradle.kts Updated SDK targets to API 36
packages/types-android/src/lib/android/org.nativescript.widgets.d.ts Added type declarations for new Java methods
packages/core/utils/native-helper.d.ts Added TypeScript signatures for new edge-to-edge Window overload
packages/core/utils/native-helper.android.ts Exported new getter/setter for ignoreEdgeToEdgeOnOlderDevices flag
packages/core/utils/native-helper-for-android.ts Implemented Window overload support for enableEdgeToEdge
packages/core/ui/core/view/index.android.ts Removed debug console.log and added edge-to-edge support for dialog windows
packages/core/core-types/index.ts Updated AndroidOverflow type to include AndroidOverflowMultiple as standalone option

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 201 to 258
public void setOverflowEdge(int value) {
overflowEdge = value;

if (value == OverflowEdgeIgnore) {
ViewCompat.setOnApplyWindowInsetsListener(this, null);
ViewCompat.requestApplyInsets(this);
} else if (windowInsetsListener == null) {
// if incoming inset is empty and previous inset is empty return consumed
// an incoming empty inset is one way to detect a consumed inset e.g multiple views consumed top/bottom
return;
}

if (windowInsetsListener == null) {
windowInsetsListener = new androidx.core.view.OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowInsetsCompat insets) {
if (insets.isConsumed()) {
if (insets.isConsumed() || overflowEdge == OverflowEdgeIgnore) {
return insets;
}
if (v instanceof LayoutBase) {
LayoutBase base = (LayoutBase) v;

// should not occur but if it does return the inset
if (overflowEdge == OverflowEdgeIgnore) {
return insets;
}

Insets statusBar = insets.getInsets(WindowInsetsCompat.Type.statusBars());
Insets navBar = insets.getInsets(WindowInsetsCompat.Type.navigationBars());
Insets ime = insets.getInsets(WindowInsetsCompat.Type.ime());

int insetLeft = navBar.left;
int insetRight = navBar.right;
int insetBottom = Math.max(navBar.bottom, ime.bottom);

insetBuffer.put(EMPTY_INSETS, 0, 32);
insetBuffer.rewind();

if (overflowEdge == OverflowEdgeNone) {
base.applyingEdges = true;
v.setPadding(mPaddingLeft + insetLeft, mPaddingTop + statusBar.top, mPaddingRight + insetRight, mPaddingBottom + insetBottom);
edgeInsets = Insets.of(insetLeft, statusBar.top, insetRight, insetBottom);
base.applyingEdges = false;
return WindowInsetsCompat.CONSUMED;
}

if (base.insetListener != null) {
if (overflowEdge == OverflowEdgeDontApply) {
// if incoming inset is empty and previous inset is empty return consumed
// an incoming empty inset is one way to detect a consumed inset e.g multiple views consumed top/bottom
if (Insets.NONE.equals(statusBar) && Insets.NONE.equals(navBar) && Insets.NONE.equals(ime) && Insets.NONE.equals(edgeInsets)) {
return WindowInsetsCompat.CONSUMED;
}

IntBuffer insetData = insetBuffer.asIntBuffer();

boolean leftPreviouslyConsumed = insetLeft == 0;
boolean topPreviouslyConsumed = statusBar.top == 0;
boolean rightPreviouslyConsumed = insetRight == 0;
boolean bottomPreviouslyConsumed = insetBottom == 0;


insetData.put(0, insetLeft).put(1, statusBar.top).put(2, insetRight).put(3, insetBottom).put(4, leftPreviouslyConsumed ? 1 : 0).put(5, topPreviouslyConsumed ? 1 : 0).put(6, rightPreviouslyConsumed ? 1 : 0).put(7, bottomPreviouslyConsumed ? 1 : 0);

base.insetListener.onApplyWindowInsets(insetBuffer);

int leftInset = insetData.get(0);
int topInset = insetData.get(1);
int rightInset = insetData.get(2);
int bottomInset = insetData.get(3);

boolean leftConsumed = insetData.get(4) > 0;
boolean topConsumed = insetData.get(5) > 0;
boolean rightConsumed = insetData.get(6) > 0;
boolean bottomConsumed = insetData.get(7) > 0;

if (leftConsumed && topConsumed && rightConsumed && bottomConsumed) {
edgeInsets = Insets.of(leftInset, topInset, rightInset, bottomInset);
base.setPadding(leftInset, topInset, rightInset, bottomInset);
return new WindowInsetsCompat.Builder().setInsets(WindowInsetsCompat.Type.systemBars(), Insets.NONE).build();
}

base.setPadding(leftPreviouslyConsumed ? 0 : leftInset, topPreviouslyConsumed ? 0 : topInset, rightPreviouslyConsumed ? 0 : rightInset, bottomPreviouslyConsumed ? 0 : bottomInset);
if (!(v instanceof LayoutBase)) return insets;
LayoutBase base = (LayoutBase) v;

// restore inset edge if not consumed
Insets statusBar = insets.getInsets(WindowInsetsCompat.Type.statusBars());
Insets navBar = insets.getInsets(WindowInsetsCompat.Type.navigationBars());
Insets ime = insets.getInsets(WindowInsetsCompat.Type.ime());

if (!(leftPreviouslyConsumed || leftConsumed)) {
leftInset = insetLeft;
}
int insetLeft = navBar.left;
int insetRight = navBar.right;
int insetBottom = Math.max(navBar.bottom, ime.bottom);

if (!(topPreviouslyConsumed || topConsumed)) {
topInset = statusBar.top;
}
resetInset();

if (!(rightPreviouslyConsumed || rightConsumed)) {
rightInset = insetRight;
}

if (!(bottomPreviouslyConsumed || bottomConsumed)) {
bottomInset = insetBottom;
}

edgeInsets = Insets.of(leftPreviouslyConsumed ? 0 : leftInset, topPreviouslyConsumed ? 0 : topInset, rightPreviouslyConsumed ? 0 : rightInset, bottomPreviouslyConsumed ? 0 : bottomInset);

return new WindowInsetsCompat.Builder().setInsets(WindowInsetsCompat.Type.systemBars(), Insets.of(leftPreviouslyConsumed || leftConsumed ? 0 : leftInset, topPreviouslyConsumed || topConsumed ? 0 : topInset, rightPreviouslyConsumed || rightConsumed ? 0 : rightInset, bottomPreviouslyConsumed || bottomConsumed ? 0 : bottomInset)).build();
}
}

boolean overflowLeftConsume = (overflowEdge & OverflowEdgeLeft) == OverflowEdgeLeft;
boolean overflowTopConsume = (overflowEdge & OverflowEdgeTop) == OverflowEdgeTop;
boolean overflowRightConsume = (overflowEdge & OverflowEdgeRight) == OverflowEdgeRight;
boolean overflowBottomConsume = (overflowEdge & OverflowEdgeBottom) == OverflowEdgeBottom;

boolean overflowLeft = (overflowEdge & OverflowEdgeLeftDontConsume) == OverflowEdgeLeftDontConsume;
boolean overflowTop = (overflowEdge & OverflowEdgeTopDontConsume) == OverflowEdgeTopDontConsume;
boolean overflowRight = (overflowEdge & OverflowEdgeRightDontConsume) == OverflowEdgeRightDontConsume;
boolean overflowBottom = (overflowEdge & OverflowEdgeBottomDontConsume) == OverflowEdgeBottomDontConsume;
WindowInsetsCompat consumed = new WindowInsetsCompat.Builder()
.setInsets(WindowInsetsCompat.Type.systemBars(), Insets.NONE).build();

if (overflowEdge == OverflowEdgeNone) {
base.applyingEdges = true;
v.setPadding(mPaddingLeft + insetLeft, mPaddingTop + statusBar.top,
mPaddingRight + insetRight, mPaddingBottom + insetBottom);
edgeInsets = Insets.of(insetLeft, statusBar.top, insetRight, insetBottom);
base.applyingEdges = false;
return consumed;
}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The OverflowEdgeDontApply handling has been completely removed from the window insets listener, but the constant and API support for 'dont-apply' still exist (see core-types/index.ts line 10 and ui/core/view/index.android.ts lines 1674, 1691-1692). This creates a situation where the API accepts 'dont-apply' as a valid value but the implementation no longer handles it, resulting in undefined behavior. Either the implementation should be restored or the API should be updated to remove support for 'dont-apply' and mark it as deprecated.

Copilot uses AI. Check for mistakes.

public static void enableEdgeToEdge(Activity activity, Window window, @Nullable HandleDarkMode handleDarkMode) {
if (activity instanceof ComponentActivity) {
if (Utils.ignoreEdgeToEdgeOnOlderDevices && Build.VERSION.SDK_INT <= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The constant Build.VERSION_CODES.UPSIDE_DOWN_CAKE does not exist in the Android SDK. Android API 34 is represented by Build.VERSION_CODES.UPSIDE_DOWN_CAKE but this constant is only available starting from API 35 (when building against compileSdk 35+). The actual value should be the integer constant 34, or you should use a constant that's available at compile time. Consider using Build.VERSION.SDK_INT < 35 or defining your own constant like private static final int API_34 = 34 to check against Android 14 (API 34).

Copilot uses AI. Check for mistakes.
}

if (opts) {
if (typeof options.handleDarkMode === 'function') {
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The variable options is used instead of opts when checking for handleDarkMode. This should be opts.handleDarkMode to properly handle both the single-parameter and two-parameter overloads. When windowOrOptions is a Window instance, options contains the actual options, but when it's EdgeToEdgeOptions, opts contains the options.

Copilot uses AI. Check for mistakes.
}

if (opts) {
if (typeof options.handleDarkMode === 'function') {
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

This line references options.handleDarkMode but should reference opts.handleDarkMode. When the function is called with only 2 parameters (activity and EdgeToEdgeOptions), the options parameter is undefined, causing a runtime error. The variable opts is correctly set to point to the right options object in both overload cases (lines 400-403).

Copilot uses AI. Check for mistakes.
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