[Android] Disable dragging on bottom sheets on ChromeOS

Nicolas Pomepuy git at videolan.org
Mon Oct 7 09:28:52 UTC 2024


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Sep 30 09:59:47 2024 +0200| [b5777a39c5a7fe72adba45cd01519e654e2b0ad8] | committer: Nicolas Pomepuy

Disable dragging on bottom sheets on ChromeOS

> https://code.videolan.org/videolan/vlc-android/commit/b5777a39c5a7fe72adba45cd01519e654e2b0ad8
---

 .../vlc/gui/dialogs/VLCBottomSheetDialogFragment.kt         | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VLCBottomSheetDialogFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VLCBottomSheetDialogFragment.kt
index c993ef819d..abf9f1763f 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VLCBottomSheetDialogFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VLCBottomSheetDialogFragment.kt
@@ -1,5 +1,6 @@
 package org.videolan.vlc.gui.dialogs
 
+import android.app.Dialog
 import android.content.DialogInterface
 import android.content.res.Configuration
 import android.os.Bundle
@@ -14,6 +15,7 @@ import androidx.annotation.LayoutRes
 import androidx.lifecycle.MutableLiveData
 import androidx.lifecycle.lifecycleScope
 import com.google.android.material.bottomsheet.BottomSheetBehavior
+import com.google.android.material.bottomsheet.BottomSheetDialog
 import com.google.android.material.bottomsheet.BottomSheetDialogFragment
 import kotlinx.coroutines.Job
 import kotlinx.coroutines.launch
@@ -93,6 +95,17 @@ abstract class VLCBottomSheetDialogFragment : BottomSheetDialogFragment() {
 
     }
 
+    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
+        val bottomSheetDialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
+        if (AndroidDevices.isChromeBook) bottomSheetDialog.setOnShowListener {
+            bottomSheetDialog.findViewById<FrameLayout>(com.google.android.material.R.id.design_bottom_sheet)
+                ?.let { bottomSheet ->
+                    BottomSheetBehavior.from(bottomSheet).isDraggable = false
+                }
+        }
+        return bottomSheetDialog
+    }
+
     private fun simulateKeyPress(key: Int) {
         view?.let {
             val inputConnection = BaseInputConnection(



More information about the Android mailing list