Skip to content

ADFA-3207: Resolve window inset issues#1058

Open
dara-abijo-adfa wants to merge 5 commits intostagefrom
ADFA-3207-nav-button-obstructs-file-tree
Open

ADFA-3207: Resolve window inset issues#1058
dara-abijo-adfa wants to merge 5 commits intostagefrom
ADFA-3207-nav-button-obstructs-file-tree

Conversation

@dara-abijo-adfa
Copy link
Contributor

  • Removed redundant paddings
  • Added necessary insets padding

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough
  • Release notes:

    • Fix: Resolve window inset issues by centralizing bottom inset padding application and removing redundant fragment-level insets handling.
    • MainActivity: Added override/on-apply handling to forward WindowInsetsCompat to binding.root via applyBottomWindowInsetsPadding to ensure bottom padding is applied.
    • BaseEditorActivity: Calls applyBottomWindowInsetsPadding(insets) on binding.root during window-insets application.
    • TemplateDetailsFragment & TemplateListFragment: Removed fragment-level WindowInsetsCompat listeners and their bottom-padding adjustments.
    • Insets utility: New View extension applyBottomWindowInsetsPadding(insets: WindowInsetsCompat) added to apply system bar bottom inset to view padding.
    • Layout updates: Removed android:fitsSystemWindows="true" from fragment_delete_project.xml and fragment_saved_projects.xml.
  • Risks / best-practice violations:

    • ⚠️ Potential duplicated/competing inset handling — child activities now apply bottom insets on binding.root while a parent (EdgeToEdgeIDEActivity/decor view) may already handle insets, risking double padding or conflicts.
    • ⚠️ Inconsistent strategy — activities apply insets but fragments no longer do; mixed approaches increase risk of layout inconsistencies between screens and maintenance complexity.
    • ⚠️ Removal of fitsSystemWindows reduces defensive fallback — if runtime inset listeners fail or aren’t attached in some states, UI elements could be obscured by system bars.
    • ⚠️ Lifecycle/ordering concerns — applying/requesting insets during onCreate or via listeners can cause multiple applications or transient layout jumps if not coordinated with view attachment and parent inset handling.
    • ⚠️ Lack of explicit coordination with parent inset hooks — new calls to applyBottomWindowInsetsPadding don’t integrate with existing parent onApplyWindowInsets/onApplySystemBarInsets hooks, increasing chance of duplicated logic or missed cases.

Walkthrough

Centralizes window-insets handling: adds activity-level onApplyWindowInsets calls and a View extension to apply bottom padding, removes fragment-level insets listeners, and drops fitsSystemWindows from two layouts.

Changes

Cohort / File(s) Summary
Activity insets
app/src/main/java/com/itsaky/androidide/activities/MainActivity.kt, app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt
Adds override fun onApplyWindowInsets(insets: WindowInsetsCompat) and invokes applyBottomWindowInsetsPadding(insets) on the root binding to apply bottom inset padding.
Fragment-level removal
app/src/main/java/com/itsaky/androidide/fragments/TemplateDetailsFragment.kt, app/src/main/java/com/itsaky/androidide/fragments/TemplateListFragment.kt
Removes fragment-level WindowInsets listeners and associated bottom-padding adjustments.
Layout XML cleanup
app/src/main/res/layout/fragment_delete_project.xml, app/src/main/res/layout/fragment_saved_projects.xml
Removes android:fitsSystemWindows="true" attributes from affected containers.
Inset utility
common/src/main/java/com/itsaky/androidide/utils/InsetUtils.kt
Adds fun View.applyBottomWindowInsetsPadding(insets: WindowInsetsCompat) extension that reads system bar bottom inset and updates view bottom padding.

Sequence Diagram(s)

sequenceDiagram
    participant System as WindowInsets system
    participant Activity as MainActivity / BaseEditorActivity
    participant View as Binding.root (View)
    participant Util as applyBottomWindowInsetsPadding

    System->>Activity: deliver WindowInsetsCompat
    Activity->>View: onApplyWindowInsets(insets)
    View->>Util: applyBottomWindowInsetsPadding(insets)
    Util->>View: updatePadding(bottom = insets.getInsets(...).bottom)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • jatezzz
  • Daniel-ADFA
  • jomen-adfa
  • itsaky-adfa

Poem

🐰
I hop where paddings softly land,
Insets guided by a steadier hand.
Fragments lighter, layouts clear,
Bottom gaps vanish—cheer, cheer, cheer!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 'ADFA-3207: Resolve window inset issues' directly relates to the main change: consolidating window insets handling by removing redundant legacy implementations and adding centralized insets padding application.
Description check ✅ Passed The description 'Removed redundant paddings' and 'Added necessary insets padding' accurately reflects the changeset: removing legacy window insets listeners and fitsSystemWindows attributes while adding centralized applyBottomWindowInsetsPadding handling.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ADFA-3207-nav-button-obstructs-file-tree

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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt`:
- Around line 576-580: The onApplyWindowInsets listener registered in
BaseEditorActivity via ViewCompat.setOnApplyWindowInsetsListener(binding.root)
needs an immediate inset dispatch so the bottom padding is applied on first
render; after registering the listener call
ViewCompat.requestApplyInsets(binding.root) to force insets to be delivered
right away (keep the listener body that updates padding from
windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())).

In `@app/src/main/java/com/itsaky/androidide/activities/MainActivity.kt`:
- Around line 113-117: The OnApplyWindowInsets listener on binding.root
(registered via ViewCompat.setOnApplyWindowInsetsListener) may miss the initial
insets because it is attached after layout; after registering the listener, call
ViewCompat.requestApplyInsets(binding.root) so the initial inset pass is
delivered and the bottom padding set by v.updatePadding(bottom = insets.bottom)
is applied immediately.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4d97e43d-82f6-4bb8-a4c0-e08c5238ac8a

📥 Commits

Reviewing files that changed from the base of the PR and between 1f41fce and b44db83.

📒 Files selected for processing (6)
  • app/src/main/java/com/itsaky/androidide/activities/MainActivity.kt
  • app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt
  • app/src/main/java/com/itsaky/androidide/fragments/TemplateDetailsFragment.kt
  • app/src/main/java/com/itsaky/androidide/fragments/TemplateListFragment.kt
  • app/src/main/res/layout/fragment_delete_project.xml
  • app/src/main/res/layout/fragment_saved_projects.xml
💤 Files with no reviewable changes (2)
  • app/src/main/java/com/itsaky/androidide/fragments/TemplateDetailsFragment.kt
  • app/src/main/java/com/itsaky/androidide/fragments/TemplateListFragment.kt

Copy link
Contributor

@itsaky-adfa itsaky-adfa left a comment

Choose a reason for hiding this comment

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

Requesting a minor (nitpicky?) change. Looks good otherwise.

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.

🧹 Nitpick comments (1)
common/src/main/java/com/itsaky/androidide/utils/InsetUtils.kt (1)

67-70: Consider reusing getSystemBarInsets for consistency.

The new function uses insets.getInsets(WindowInsetsCompat.Type.systemBars()) directly, while the existing getSystemBarInsets(insets) function (lines 45-60) handles API-level differences and also includes displayCutout() for API >= R. This creates an inconsistency in how insets are retrieved across the file.

Reusing the existing function would ensure consistent behavior and align with the commit message intent ("Reuse methods").

♻️ Suggested refactor to reuse existing function
 fun View.applyBottomWindowInsetsPadding(insets: WindowInsetsCompat) {
-    val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
+    val systemBars = getSystemBarInsets(insets)
     updatePadding(bottom = systemBars.bottom)
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@common/src/main/java/com/itsaky/androidide/utils/InsetUtils.kt` around lines
67 - 70, The function applyBottomWindowInsetsPadding currently calls
insets.getInsets(WindowInsetsCompat.Type.systemBars()) directly; change it to
reuse the existing getSystemBarInsets(insets) helper so API-level handling and
displayCutout support are preserved—retrieve the bottom inset from
getSystemBarInsets(insets) and pass it to updatePadding(bottom = ...); look for
the functions applyBottomWindowInsetsPadding and getSystemBarInsets to make this
replacement.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@common/src/main/java/com/itsaky/androidide/utils/InsetUtils.kt`:
- Around line 67-70: The function applyBottomWindowInsetsPadding currently calls
insets.getInsets(WindowInsetsCompat.Type.systemBars()) directly; change it to
reuse the existing getSystemBarInsets(insets) helper so API-level handling and
displayCutout support are preserved—retrieve the bottom inset from
getSystemBarInsets(insets) and pass it to updatePadding(bottom = ...); look for
the functions applyBottomWindowInsetsPadding and getSystemBarInsets to make this
replacement.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2651c28b-acc7-499e-ae43-df86ae4efd0e

📥 Commits

Reviewing files that changed from the base of the PR and between 0371dcc and ed5b198.

📒 Files selected for processing (3)
  • app/src/main/java/com/itsaky/androidide/activities/MainActivity.kt
  • app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt
  • common/src/main/java/com/itsaky/androidide/utils/InsetUtils.kt
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt
  • app/src/main/java/com/itsaky/androidide/activities/MainActivity.kt

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