Skip to content

Commit 2354af1

Browse files
ADFA-4320 Paper cut: Fix for swiping bottom sheet tabs incorrectly opening file menu (#1390)
* Fix for swiping bottom sheet tabs incorrectly opening file menu * ADFA-4320 Skip drawer fling-open when swiping bottom sheet tabs 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. * ADFA-4320 Move tab-strip check into onFling and harden against teardown 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.
1 parent 698df84 commit 2354af1

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import android.content.Intent
2222
import android.content.ServiceConnection
2323
import android.content.res.Configuration
2424
import android.graphics.Color
25+
import android.graphics.Rect
2526
import android.graphics.drawable.GradientDrawable
2627
import android.os.Build
2728
import android.os.Bundle
@@ -1652,7 +1653,9 @@ abstract class BaseEditorActivity :
16521653
}
16531654

16541655
// Filter out diagonal flings so only an intentional right swipe opens the drawer.
1655-
if (isDrawerOpenFling) {
1656+
// A horizontal fling that started on the bottom-sheet tab strip is the user
1657+
// scrolling tabs, not asking for the drawer.
1658+
if (isDrawerOpenFling && !isTouchOnBottomSheetTabs(e1)) {
16561659
binding.editorDrawerLayout.openDrawer(GravityCompat.START)
16571660
return true
16581661
}
@@ -1672,6 +1675,13 @@ abstract class BaseEditorActivity :
16721675
return super.dispatchTouchEvent(ev)
16731676
}
16741677

1678+
private fun isTouchOnBottomSheetTabs(ev: MotionEvent): Boolean {
1679+
val tabs = contentOrNull?.bottomSheet?.binding?.tabs ?: return false
1680+
val rect = Rect()
1681+
if (!tabs.getGlobalVisibleRect(rect)) return false
1682+
return rect.contains(ev.rawX.toInt(), ev.rawY.toInt())
1683+
}
1684+
16751685
private fun showTooltip(tag: String) {
16761686
TooltipManager.showIdeCategoryTooltip(
16771687
context = this,

0 commit comments

Comments
 (0)