[Android] Expand Context menu on landscape

Geoffrey Métais git at videolan.org
Wed Nov 21 10:29:05 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Nov 20 18:25:37 2018 +0100| [aa1149c54ba14ceebf3d0f3138657dbf980e0a09] | committer: Geoffrey Métais

Expand Context menu on landscape

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

 .../src/org/videolan/vlc/gui/dialogs/ContextSheet.kt   | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt b/vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt
index ae139b074..9d1776110 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt
@@ -21,14 +21,14 @@
 package org.videolan.vlc.gui.dialogs
 
 import android.os.Bundle
-import com.google.android.material.bottomsheet.BottomSheetDialogFragment
-import androidx.fragment.app.FragmentActivity
-import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
+import android.widget.FrameLayout
 import android.widget.TextView
+import com.google.android.material.bottomsheet.BottomSheetBehavior
+import com.google.android.material.bottomsheet.BottomSheetDialog
+import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.launch
 import org.videolan.tools.coroutineScope
 import org.videolan.vlc.R
@@ -75,7 +75,15 @@ class ContextSheet : com.google.android.material.bottomsheet.BottomSheetDialogFr
         list.adapter = ContextAdapter()
         val flags = arguments?.getInt(CTX_FLAGS_KEY) ?: 0
         options = populateOptions(flags)
-        if (!AndroidDevices.isPhone) coroutineScope.launch { dialog.window.setLayout(resources.getDimensionPixelSize(R.dimen.default_context_width), ViewGroup.LayoutParams.MATCH_PARENT) }
+        if (!AndroidDevices.isPhone) coroutineScope.launch {
+            dialog.window.setLayout(resources.getDimensionPixelSize(R.dimen.default_context_width), ViewGroup.LayoutParams.MATCH_PARENT)
+        }
+        coroutineScope.launch(Dispatchers.Main) {
+            val bottomSheet = (dialog as BottomSheetDialog).findViewById<FrameLayout>(com.google.android.material.R.id.design_bottom_sheet)
+            bottomSheet?.let {
+                val bsb = BottomSheetBehavior.from(it)
+                if (bsb.state == BottomSheetBehavior.STATE_COLLAPSED) bsb.state = BottomSheetBehavior.STATE_EXPANDED }
+        }
     }
 
     private fun populateOptions(flags: Int) = mutableListOf<CtxOption>().apply {



More information about the Android mailing list