From e3a2b32de74447d0ba659e0964fc7fd51236c6c5 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 10 Jul 2022 13:01:24 +0200 Subject: [PATCH 1/2] enable chapter name in portrait mode --- .../github/libretube/fragments/PlayerFragment.kt | 10 +++++++--- .../res/layout/exo_styled_player_control_view.xml | 5 ++--- app/src/main/res/layout/fragment_player.xml | 13 ++++++------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index 39cd2819c..d93ec04be 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -336,7 +336,7 @@ class PlayerFragment : Fragment() { binding.linLayout.visibility = View.GONE playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit) playerBinding.exoTitle.visibility = View.VISIBLE - if (chapters.isNotEmpty()) playerBinding.chapterLL.visibility = View.VISIBLE + playerBinding.chapterLL.isClickable = true val mainActivity = activity as MainActivity val fullscreenOrientationPref = PreferenceHelper @@ -373,7 +373,7 @@ class PlayerFragment : Fragment() { binding.linLayout.visibility = View.VISIBLE playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen) playerBinding.exoTitle.visibility = View.INVISIBLE - playerBinding.chapterLL.visibility = View.INVISIBLE + playerBinding.chapterLL.isClickable = false scaleControls(1F) @@ -715,6 +715,8 @@ class PlayerFragment : Fragment() { if (response.chapters != null) { chapters = response.chapters initializeChapters() + // disabling chapterName click in portrait mode + playerBinding.chapterLL.isClickable = false } // set default playback speed @@ -976,11 +978,12 @@ class PlayerFragment : Fragment() { binding.chaptersRecView.adapter = ChaptersAdapter(chapters, exoPlayer) binding.chaptersRecView.visibility = View.VISIBLE - // enable chapters in the player + // enable the chapters dialog in the player val titles = mutableListOf() chapters.forEach { titles += it.title!! } + playerBinding.chapterLL.visibility = View.VISIBLE playerBinding.chapterLL.setOnClickListener { MaterialAlertDialogBuilder(requireContext()) .setTitle(R.string.chapters) @@ -1213,6 +1216,7 @@ class PlayerFragment : Fragment() { } } + // lock the player private fun lockPlayer(isLocked: Boolean) { val visibility = if (isLocked) View.VISIBLE else View.GONE diff --git a/app/src/main/res/layout/exo_styled_player_control_view.xml b/app/src/main/res/layout/exo_styled_player_control_view.xml index 5363a9d74..b3ed9c465 100644 --- a/app/src/main/res/layout/exo_styled_player_control_view.xml +++ b/app/src/main/res/layout/exo_styled_player_control_view.xml @@ -83,8 +83,8 @@ android:id="@+id/speed_text" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginHorizontal="5dp" android:layout_gravity="center" + android:layout_marginHorizontal="5dp" android:padding="@dimen/exo_icon_padding" android:text="1x" android:textColor="#FFFFFF" /> @@ -93,8 +93,8 @@ android:id="@+id/quality_text" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginHorizontal="5dp" android:layout_gravity="center" + android:layout_marginHorizontal="5dp" android:padding="@dimen/exo_icon_padding" android:text="@string/hls" android:textColor="#FFFFFF" /> @@ -162,7 +162,6 @@ android:layout_height="15dp" android:layout_gravity="center" android:layout_marginStart="3dp" - android:layout_marginTop="2dp" android:src="@drawable/ic_arrow_right" /> diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index cc011b5e0..cb1286c56 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -49,7 +49,7 @@ android:id="@+id/player_description_arrow" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentRight="true" + android:layout_alignParentEnd="true" android:layout_centerInParent="true" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" @@ -73,7 +73,7 @@ @@ -119,7 +119,6 @@ android:id="@+id/chapters_recView" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_below="@id/comments_toggle" android:layout_marginHorizontal="3dp" android:layout_marginTop="20dp" android:nestedScrollingEnabled="false" @@ -245,7 +244,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_centerVertical="true" - android:layout_marginLeft="5dp" + android:layout_marginStart="5dp" android:layout_toStartOf="@+id/player_subscribe" android:layout_toEndOf="@+id/player_channelImage" android:ellipsize="end" @@ -297,7 +296,7 @@ android:id="@+id/commentsToggle_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="8dp" + android:layout_marginStart="8dp" android:text="@string/comments" android:textSize="17sp" app:layout_constraintStart_toStartOf="parent" @@ -307,7 +306,7 @@ android:id="@+id/commentsToggle_imageView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="3dp" + android:layout_marginEnd="3dp" android:src="@drawable/ic_arrow_up_down" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" From bedfb135394be2d548250a6a92eb99d17cb72958 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 10 Jul 2022 13:56:17 +0200 Subject: [PATCH 2/2] custom shuffle button --- .../libretube/fragments/PlayerFragment.kt | 14 +++++++++++++- app/src/main/res/drawable/ic_repeat.xml | 10 ++++++++++ .../layout/exo_styled_player_control_view.xml | 18 +++++++++++------- app/src/main/res/values/style.xml | 10 ++++++++++ 4 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 app/src/main/res/drawable/ic_repeat.xml diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index d93ec04be..3ef75ae1b 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -6,6 +6,7 @@ import android.app.PictureInPictureParams import android.content.Context import android.content.Intent import android.content.pm.ActivityInfo +import android.graphics.Color import android.graphics.Rect import android.net.Uri import android.os.Build @@ -685,7 +686,6 @@ class PlayerFragment : Fragment() { setShowSubtitleButton(true) setShowNextButton(false) setShowPreviousButton(false) - setRepeatToggleModes(RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL) // controllerShowTimeoutMs = 1500 controllerHideOnTouch = true useController = false @@ -808,6 +808,18 @@ class PlayerFragment : Fragment() { } }) + // repeat toggle button + playerBinding.repeatToggle.setOnClickListener { + if (exoPlayer.repeatMode == RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL) { + // turn off repeat mode + exoPlayer.repeatMode = RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE + playerBinding.repeatToggle.setColorFilter(Color.GRAY) + } else { + exoPlayer.repeatMode = RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL + playerBinding.repeatToggle.setColorFilter(Color.WHITE) + } + } + // share button binding.relPlayerShare.setOnClickListener { val shareDialog = ShareDialog(videoId!!, false) diff --git a/app/src/main/res/drawable/ic_repeat.xml b/app/src/main/res/drawable/ic_repeat.xml new file mode 100644 index 000000000..7b4c81168 --- /dev/null +++ b/app/src/main/res/drawable/ic_repeat.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/exo_styled_player_control_view.xml b/app/src/main/res/layout/exo_styled_player_control_view.xml index b3ed9c465..12c8864c1 100644 --- a/app/src/main/res/layout/exo_styled_player_control_view.xml +++ b/app/src/main/res/layout/exo_styled_player_control_view.xml @@ -75,7 +75,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginHorizontal="5dp" - android:background="#00FFFFFF" + android:background="?attr/selectableItemBackground" android:padding="@dimen/exo_icon_padding" android:src="@drawable/ic_aspect_ratio" /> @@ -85,6 +85,7 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginHorizontal="5dp" + android:background="?attr/selectableItemBackground" android:padding="@dimen/exo_icon_padding" android:text="1x" android:textColor="#FFFFFF" /> @@ -95,6 +96,7 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginHorizontal="5dp" + android:background="?attr/selectableItemBackground" android:padding="@dimen/exo_icon_padding" android:text="@string/hls" android:textColor="#FFFFFF" /> @@ -114,7 +116,7 @@ + android:layout_marginStart="5dp"> + android:id="@+id/repeat_toggle" + style="@style/PlayerButton" + android:src="@drawable/ic_repeat" + app:tint="@android:color/darker_gray"/> + style="@style/PlayerButton" /> diff --git a/app/src/main/res/values/style.xml b/app/src/main/res/values/style.xml index 3db13793b..759b7f2b1 100644 --- a/app/src/main/res/values/style.xml +++ b/app/src/main/res/values/style.xml @@ -114,4 +114,14 @@ + + \ No newline at end of file