Skip to content

ADFA-1788 | Fix sidebar overlap with status bar on split-screen resize#840

Merged
jatezzz merged 3 commits intostagefrom
fix/ADFA-1788-sidebar-insets-split-screen
Jan 19, 2026
Merged

ADFA-1788 | Fix sidebar overlap with status bar on split-screen resize#840
jatezzz merged 3 commits intostagefrom
fix/ADFA-1788-sidebar-insets-split-screen

Conversation

@jatezzz
Copy link
Collaborator

@jatezzz jatezzz commented Jan 15, 2026

Description

This PR fixes a UI issue where the editor sidebar header (title and first action icon) could render behind the system status bar after resizing the app in split-screen mode.
The fix centralizes system bar inset handling in BaseEditorActivity (the most reliable inset source during window resizes) and applies the top inset as stable padding to the sidebar host, avoiding inset accumulation and layout drift.

Details

  • Applies systemBars.top padding to the editor app bar and sidebar during onApplyWindowInsets, ensuring correct behavior during split-screen resize events.
  • Removes fragment-level inset adjustments from EditorSidebarFragment, which were unreliable during window resize and risked accumulating padding/margins over repeated inset dispatches.
  • Tracks the last applied sidebar top inset to compute a stable base padding and prevent additive drift across multiple inset updates.
Screen_Recording_20260115_155428_Code.on.the.Go.mp4

Ticket

ADFA-1788

Observation

  • Insets are most reliably delivered to the Activity root during split-screen resizes; fragment-level inset callbacks may be skipped or receive incomplete values depending on the host view hierarchy and inset consumption.
  • The sidebar padding logic uses the previous inset value to derive a consistent base padding and avoid repeatedly stacking inset values on each dispatch.
  • This approach reduces coupling and keeps inset handling in a single, predictable location (the Activity).

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough
  • ADFA-1788: Fix sidebar overlap with status bar on split-screen resize

Changes

  • Centralized system-bar inset handling in BaseEditorActivity.onApplyWindowInsets() and removed fragment-level inset adjustments from EditorSidebarFragment.
  • Added sidebarLastInsetTop to track the last-applied top inset and compute a stable base padding to prevent additive drift across repeated inset dispatches.
  • Introduced applySidebarInsets(systemBars) helper to apply systemBars.top as stable top padding to the sidebar host/drawer and to editorAppBarLayout.
  • Reworked IME handling in BaseEditorActivity: derive isImeVisible from imeInsets, update bottomSheet IME visibility, clamp IME-adjusted content heights to avoid negative layout params, and adjust contentCard height when IME is visible (baseHeight minus IME) and restore to MATCH_PARENT when hidden (caching real height after layout).
  • Removed EditorSidebarFragment’s internal onApplyWindowInsets(insets: Insets) and related padding/margin updates (imports removed); inline/duplicate inset application code cleaned up.
  • Minor cleanup: removed now-unused imports and obsolete inline inset application.

Risks & Best-practice considerations

  • Mutable state risk: sidebarLastInsetTop is extra mutable state; if mismanaged it could still allow padding drift.
  • Single point of failure: Centralizing inset logic in BaseEditorActivity means a bug there affects sidebar, app bar and drawer layouts across the editor.
  • Fragment dependency: EditorSidebarFragment no longer handles its own insets and relies on the activity to deliver correct insets; delayed or missed dispatches may break sidebar layout.
  • Timing/device edge cases: Rapid split-screen resizes, foldables, or quick IME show/hide transitions can produce inconsistent inset delivery; these edge cases may still surface without exhaustive testing.
  • Regression surface: Ensure no leftover cumulative padding/margins or negative layout params remain after multiple resize/IME cycles.

Testing recommendations

  • Verify sidebar header (title and first action icon) remains fully visible after repeated split-screen resizes, orientation changes, and on foldable devices.
  • Test IME show/hide flows (normal and split-screen) to confirm contentCard height adjustments and bottomSheet IME signaling; ensure IME adjustments never produce negative layout params.
  • Stress-test rapid window-resize, multi-window transitions, and frequent IME toggles to confirm stable, non-additive inset application and no regressions.

Walkthrough

Consolidates sidebar window-inset handling into BaseEditorActivity via a new applySidebarInsets helper, removes fragment-local inset logic, and updates contentCard sizing to respond dynamically to IME visibility while preserving bottom-sheet IME signaling. (≤50 words)

Changes

Cohort / File(s) Summary
Window Insets & IME (Activity)
app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt
Adds sidebarLastInsetTop field and applySidebarInsets(systemBars) helper; centralizes sidebar/drawer inset application; updates onApplyWindowInsets to use systemBars.top for app bar padding, compute isImeVisible from imeInsets, update bottomSheet IME visibility, and adjust/cache contentCard height accordingly.
Fragment inset removal
app/src/main/java/com/itsaky/androidide/fragments/sidebar/EditorSidebarFragment.kt
Removes fragment-local onApplyWindowInsets(insets: Insets) and related margin/padding imports; inset responsibilities delegated to activity.

Sequence Diagram(s)

sequenceDiagram
    participant System as System Insets / IME
    participant Activity as BaseEditorActivity
    participant Sidebar as EditorSidebarFragment
    participant BottomSheet as BottomSheet / ContentCard
    System->>Activity: deliver window insets / IME changes
    Activity->>Activity: extract systemBars, compute imeInsets / isImeVisible
    Activity->>Activity: update editorAppBarLayout top padding
    Activity->>Sidebar: applySidebarInsets(systemBars)
    Activity->>BottomSheet: update IME visibility & adjust contentCard height (cache real height when hidden)
    Sidebar-->>Activity: no longer applies insets itself
    Activity-->>System: UI paddings/heights updated
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested Reviewers

  • itsaky-adfa
  • Daniel-ADFA
  • dara-abijo-adfa

Poem

🐇 I nudged the insets from nook to hall,
A helper hops in, tidy and small,
Cards bow and stretch when keyboards sing,
Sidebar stays put while paddings spring,
Hooray — the layout listens to all. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: addressing sidebar overlap with the status bar during split-screen resize, which aligns with the core change of centralizing inset handling.
Description check ✅ Passed The description clearly relates to the changeset, explaining the UI issue being fixed, the approach taken (centralizing insets in BaseEditorActivity), and the specific details of the implementation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt`:
- Around line 465-477: The early return when contentCardRealHeight is null
prevents the IME state update and the subsequent onSoftInputChanged() call;
change the branch in BaseEditorActivity (the block using isImeVisible and
contentCardRealHeight) so it does not return early: if contentCardRealHeight is
null, skip the height adjustment but still execute the IME-path logic that
updates isImeVisible state and invokes onSoftInputChanged(), or compute a
fallback baseHeight (e.g., use contentCard.measuredHeight or postpone only the
layout change) before calling _binding?.contentCard?.updateLayoutParams and
onSoftInputChanged(); ensure references to contentCardRealHeight,
_binding?.contentCard, isImeVisible, and onSoftInputChanged() are preserved and
always result in the state update being executed.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af0d407 and 6cf74fe.

📒 Files selected for processing (2)
  • app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt
  • app/src/main/java/com/itsaky/androidide/fragments/sidebar/EditorSidebarFragment.kt
🔇 Additional comments (4)
app/src/main/java/com/itsaky/androidide/fragments/sidebar/EditorSidebarFragment.kt (1)

33-59: LGTM! Clean removal of fragment-level inset handling.

Centralizing window insets handling in BaseEditorActivity is the right approach. Fragment-level inset callbacks can receive stale or inconsistent values during split-screen resizes, which was likely the root cause of the overlap issue.

app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt (3)

352-353: LGTM! Proper tracking field for drift prevention.

The sidebarLastInsetTop field correctly tracks the last applied inset to prevent additive padding accumulation across multiple inset updates.


485-488: LGTM!

Clean simplification - stores the inset value for use in onSwipeRevealDragProgress.


490-495: LGTM! Correct drift prevention logic.

The algorithm properly extracts the base padding by subtracting the previously applied inset, then applies the new inset. This prevents additive padding accumulation during repeated inset updates (e.g., split-screen resizes).

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@jatezzz jatezzz requested a review from a team January 16, 2026 13:04
@jatezzz jatezzz force-pushed the fix/ADFA-1788-sidebar-insets-split-screen branch from 1d8d88f to c54f8a9 Compare January 16, 2026 13:32
@jatezzz jatezzz force-pushed the fix/ADFA-1788-sidebar-insets-split-screen branch from 04b9ba4 to 0ba96f5 Compare January 19, 2026 13:14
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt`:
- Around line 459-475: The IME-adjusted height calculation in the isImeVisible
branch can produce negative values; update the logic inside the when
(isImeVisible) branch (involving contentCardRealHeight and updateLayoutParams)
to clamp the computed height to a non-negative minimum (e.g., use max(0,
baseHeight - imeInsets.bottom) or a sensible MIN_HEIGHT) before assigning it to
layout params so height never becomes negative and layout remains stable.

@jatezzz jatezzz merged commit cb3fd5b into stage Jan 19, 2026
2 checks passed
@jatezzz jatezzz deleted the fix/ADFA-1788-sidebar-insets-split-screen branch January 19, 2026 17:17
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