[Android] Improve Context menu for DPAD & large screens
Geoffrey Métais
git at videolan.org
Wed Nov 21 10:29:07 CET 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 21 10:16:50 2018 +0100| [faac05091238e524f72dc7f27ff4036f98f10917] | committer: Geoffrey Métais
Improve Context menu for DPAD & large screens
> https://code.videolan.org/videolan/vlc-android/commit/faac05091238e524f72dc7f27ff4036f98f10917
---
vlc-android/res/layout/context_item.xml | 3 ++-
vlc-android/res/values-w800dp/dimens.xml | 1 -
vlc-android/res/values/dimens.xml | 2 +-
vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt | 9 +++++----
4 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/vlc-android/res/layout/context_item.xml b/vlc-android/res/layout/context_item.xml
index 58c35b2d4..c4f60e73e 100644
--- a/vlc-android/res/layout/context_item.xml
+++ b/vlc-android/res/layout/context_item.xml
@@ -11,7 +11,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
- android:layout_marginBottom="8dp">
+ android:layout_marginBottom="8dp"
+ android:focusable="true">
<ImageView
android:id="@+id/context_option_icon"
android:layout_width="wrap_content"
diff --git a/vlc-android/res/values-w800dp/dimens.xml b/vlc-android/res/values-w800dp/dimens.xml
index a2a89ed1b..126f9f28f 100644
--- a/vlc-android/res/values-w800dp/dimens.xml
+++ b/vlc-android/res/values-w800dp/dimens.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="default_content_width">800dp</dimen>
- <dimen name="default_context_width">600dp</dimen>
<dimen name="file_picker_width">720dp</dimen>
</resources>
\ No newline at end of file
diff --git a/vlc-android/res/values/dimens.xml b/vlc-android/res/values/dimens.xml
index 90bd62db9..7cb8a377e 100644
--- a/vlc-android/res/values/dimens.xml
+++ b/vlc-android/res/values/dimens.xml
@@ -47,7 +47,7 @@
<dimen name="file_picker_height">-1px</dimen>
<dimen name="default_content_width">-1px</dimen>
- <dimen name="default_context_width">-1px</dimen>
+ <dimen name="default_context_width">512dp</dimen>
<!-- Default -->
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 9b05dcbba..b629bb76a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt
@@ -26,11 +26,11 @@ import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.TextView
+import androidx.core.content.ContextCompat
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
import org.videolan.vlc.databinding.ContextItemBinding
import org.videolan.vlc.util.*
@@ -75,10 +75,8 @@ 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 {
+ AppScope.launch(Dispatchers.Main) {
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)
@@ -116,11 +114,14 @@ class ContextSheet : com.google.android.material.bottomsheet.BottomSheetDialogFr
private val inflater: LayoutInflater by lazy(LazyThreadSafetyMode.NONE) { LayoutInflater.from(requireContext()) }
inner class ViewHolder(val binding : ContextItemBinding) : androidx.recyclerview.widget.RecyclerView.ViewHolder(binding.root) {
+ private val textColor = binding.contextOptionTitle.currentTextColor
+ private val focusedColor by lazy(LazyThreadSafetyMode.NONE) { ContextCompat.getColor(itemView.context, R.color.orange500transparent) }
init {
itemView.setOnClickListener {
receiver.onCtxAction(itemPosition, options[layoutPosition].id)
dismiss()
}
+ itemView.setOnFocusChangeListener { v, hasFocus -> binding.contextOptionTitle.setTextColor( if (hasFocus) focusedColor else textColor) }
}
}
More information about the Android
mailing list