Skip to content

ADFA-4320 Paper cut: Fix for swiping bottom sheet tabs incorrectly opening file menu#1390

Open
hal-eisen-adfa wants to merge 3 commits into
stagefrom
ADFA-4320-paper-cut-flinging-the-tabs
Open

ADFA-4320 Paper cut: Fix for swiping bottom sheet tabs incorrectly opening file menu#1390
hal-eisen-adfa wants to merge 3 commits into
stagefrom
ADFA-4320-paper-cut-flinging-the-tabs

Conversation

@hal-eisen-adfa

@hal-eisen-adfa hal-eisen-adfa commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Problem

Fling-strength swipes between bottom-pane tabs (Build Output / IDE Logs / Diagnostics / Git etc.) were triggering BaseEditorActivity's drawer-open gesture detector and popping the file tree open mid-swipe. No edge proximity required — pure horizontal velocity on the tab strip.

Change

In BaseEditorActivity.onFling, the existing isDrawerOpenFling branch now also checks !isTouchOnBottomSheetTabs(e1) before calling openDrawer. The hit-test reads contentOrNull?.bottomSheet?.binding?.tabs (safe during teardown), grabs the TabLayout's getGlobalVisibleRect, and tests (e1.rawX, e1.rawY) against it.

The check lives alongside the other fling filters (startedNearTopEdge, noFilesOpen, …) so the suppression rule is visible to anyone editing setupGestureDetector.

Scope

  • Hamburger menu unaffected (works in every bottom-pane state).
  • DrawerLayout's left-edge swipe unaffected.
  • Fullscreen exit-edge flings unaffected.
  • The no-files horizontal-fling drawer shortcut still fires for flings outside the tab strip.

Test plan

  • Open a project with at least one file. Expand the bottom pane.
  • Fling the tab strip left and right with momentum — drawer must not appear.
  • Tap the hamburger from collapsed / half-expanded / fully expanded states — drawer opens every time.
  • Swipe from the screen's left edge over the editor area — drawer still opens.
  • In the empty no-files state, do a strong rightward fling on the editor area (outside the tab strip) — drawer still opens.
  • Background → foreground → swipe tabs — no crash.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

BaseEditorActivity's drawer-open swipe handling now checks whether a right-swipe fling originates on the bottom-sheet tab strip and suppresses the drawer-open action if it does. Implementation adds an android.graphics.Rect import, a new isTouchOnBottomSheetTabs(MotionEvent) helper that performs hit-testing on the TabLayout's global bounds, and extends the GestureDetector onFling condition to gate the drawer-open action.

Changes

Drawer Gesture Suppression for Bottom-Sheet Tabs

Layer / File(s) Summary
Bottom-sheet tab hit-test and onFling condition
app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt
Adds Rect import, introduces isTouchOnBottomSheetTabs to check whether a touch's raw coordinates fall within the bottom-sheet TabLayout's global visible rectangle, and updates the onFling condition to open the drawer only when isDrawerOpenFling is true and the fling start is not on the tab strip.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • dara-abijo-adfa

Poem

🐇 A swipe on the tabs? The drawer stays tight,
No gesture shall snatch what the coder writes.
The Rect marks the bounds, the fling checks the gate,
Right-swipes on tabs simply have to wait!
Hop hop, little fix — you've earned your delight! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately describes the main change: a fix for swiping on bottom sheet tabs incorrectly opening the file menu, which is the core issue addressed in the PR.
Description check ✅ Passed The pull request description comprehensively explains the problem (drawer opening on tab swipes), the solution (hit-testing touch events against tab bounds), scope of changes, and includes a detailed test plan.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ADFA-4320-paper-cut-flinging-the-tabs

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/src/main/java/com/itsaky/androidide/ui/EditorBottomSheet.kt`:
- Around line 271-285: The drawerLockCallback object only updates the drawer
lock mode when onStateChanged is invoked, which means if the bottom sheet is
already in an expanded or half-expanded state when the callback is registered,
the drawer will remain unlocked until the next state transition occurs. After
the callback registration at the .also block where
behavior.addBottomSheetCallback is called, immediately apply the drawer lock
mode based on the bottom sheet behavior's current state using the same lock
logic (checking if the current state is STATE_COLLAPSED or STATE_HIDDEN to
unlock, otherwise lock). This ensures the drawer lock state is correct
regardless of whether the sheet is already expanded when the callback is
attached.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ccadc028-3ecf-4f41-a82a-dfc0dd0b2135

📥 Commits

Reviewing files that changed from the base of the PR and between 4d9b100 and da1e435.

📒 Files selected for processing (1)
  • app/src/main/java/com/itsaky/androidide/ui/EditorBottomSheet.kt

Comment thread app/src/main/java/com/itsaky/androidide/ui/EditorBottomSheet.kt Outdated
Tab-strip flings have enough horizontal velocity to trigger the editor
activity's drawer-open gesture detector, opening the file tree when the
user is just navigating between bottom-pane tabs.

In dispatchTouchEvent, check on ACTION_DOWN whether the touch falls
inside the bottom sheet TabLayout's global visible rect; if so, stop
forwarding the touch sequence to the gesture detector. The hamburger
button and the existing no-files horizontal-fling shortcut remain
untouched.

Reverts the bottom-sheet-state drawer lock from da1e435 — that
approach broke the hamburger because ActionBarDrawerToggle treats
LOCK_MODE_LOCKED_CLOSED as "do not open" and the lock also fired on
gestures outside the tab strip.
Code review surfaced three issues with the previous implementation:

1. content.bottomSheet.binding.tabs reads a binding chain whose root
   getter throws IllegalStateException once _binding is cleared in
   preDestroy. Touches dispatched between preDestroy and window
   teardown would crash. Switched to contentOrNull, the file's existing
   defensive helper.

2. The dispatchTouchEvent flag was set only on ACTION_DOWN, so
   ACTION_POINTER_DOWN (multi-touch) could not re-evaluate it; a second
   finger could leak past or stay stuck-suppressed.

3. The check belonged with the other fling filters (startedNearTopEdge,
   noFilesOpen, etc.) in onFling, not in dispatchTouchEvent — and onFling
   already tracks the down event as e1, so no extra state is needed.

Folded the check into the isDrawerOpenFling branch using e1. Dropped
suppressDrawerGesture and bottomSheetTabsHitRect fields; restored
dispatchTouchEvent to its pre-PR form. The hit-test now runs only when
a drawer-open fling is actually detected, not on every ACTION_DOWN.
@hal-eisen-adfa hal-eisen-adfa changed the title ADFA-4320 Fix for swiping bottom sheet tabs incorrectly opening file menu ADFA-4320 Paper cut: Fix for swiping bottom sheet tabs incorrectly opening file menu Jun 15, 2026
@jatezzz jatezzz self-requested a review June 23, 2026 15:14
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