From 3d2dafa5551ad7e1fe9290f4e29ddcb6fca0f4e8 Mon Sep 17 00:00:00 2001 From: xz-dev Date: Tue, 25 Apr 2023 16:20:05 +0800 Subject: [PATCH] Passthrough comments sheet outside event --- .../com/github/libretube/ui/sheets/CommentsSheet.kt | 12 ++++++++++++ .../libretube/ui/sheets/ExpandedBottomSheet.kt | 5 +---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/sheets/CommentsSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/CommentsSheet.kt index f3f5f1d4ec..8f84324757 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/CommentsSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/CommentsSheet.kt @@ -90,6 +90,18 @@ class CommentsSheet : ExpandedBottomSheet() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { val dialog = super.onCreateDialog(savedInstanceState) + // BottomSheetDialogFragment passthrough user outside touch event + dialog.setOnShowListener { + dialog.findViewById(R.id.touch_outside)?.apply { + setOnTouchListener { v, event -> + event.setLocation(event.rawX - v.x, event.rawY - v.y) + activity?.dispatchTouchEvent(event) + v.performClick() + false + } + } + } + dialog.apply { setOnKeyListener { _, keyCode, _ -> if (keyCode == KeyEvent.KEYCODE_BACK) { diff --git a/app/src/main/java/com/github/libretube/ui/sheets/ExpandedBottomSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/ExpandedBottomSheet.kt index 94b8959f0b..533aef983e 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/ExpandedBottomSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/ExpandedBottomSheet.kt @@ -29,10 +29,7 @@ open class ExpandedBottomSheet : BottomSheetDialogFragment() { return dialog } - fun show(fragmentManager: FragmentManager) = show( - fragmentManager, - null - ) + fun show(fragmentManager: FragmentManager) = show(fragmentManager, null) override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) { super.onPictureInPictureModeChanged(isInPictureInPictureMode)