From 48813a12a3277a7076c43368918cbd52cfbb8a58 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 10 Jul 2022 18:14:15 +0200 Subject: [PATCH] chapter name clickable in portrait --- .../libretube/fragments/PlayerFragment.kt | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 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 9b75d1928..be06f4139 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -262,9 +262,7 @@ class PlayerFragment : Fragment() { // video description and chapters toggle binding.playerTitleLayout.setOnClickListener { - binding.playerDescriptionArrow.animate().rotationBy(180F).setDuration(250).start() - binding.descLinLayout.visibility = - if (binding.descLinLayout.isVisible) View.GONE else View.VISIBLE + toggleDescription() } binding.commentsToggle.setOnClickListener { @@ -338,7 +336,6 @@ class PlayerFragment : Fragment() { binding.linLayout.visibility = View.GONE playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit) playerBinding.exoTitle.visibility = View.VISIBLE - playerBinding.chapterLL.isClickable = true val mainActivity = activity as MainActivity val fullscreenOrientationPref = PreferenceHelper @@ -375,7 +372,6 @@ class PlayerFragment : Fragment() { binding.linLayout.visibility = View.VISIBLE playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen) playerBinding.exoTitle.visibility = View.INVISIBLE - playerBinding.chapterLL.isClickable = false scaleControls(1F) @@ -390,6 +386,12 @@ class PlayerFragment : Fragment() { playerBinding.exoPlayPause.scaleY = scaleFactor } + private fun toggleDescription() { + binding.playerDescriptionArrow.animate().rotationBy(180F).setDuration(250).start() + binding.descLinLayout.visibility = + if (binding.descLinLayout.isVisible) View.GONE else View.VISIBLE + } + private fun toggleComments() { binding.commentsRecView.visibility = if (binding.commentsRecView.isVisible) View.GONE else View.VISIBLE @@ -716,8 +718,6 @@ 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 @@ -1012,13 +1012,17 @@ class PlayerFragment : Fragment() { } playerBinding.chapterLL.visibility = View.VISIBLE playerBinding.chapterLL.setOnClickListener { - MaterialAlertDialogBuilder(requireContext()) - .setTitle(R.string.chapters) - .setItems(titles.toTypedArray()) { _, index -> - val position = chapters[index].start!! * 1000 - exoPlayer.seekTo(position) - } - .show() + if (isFullScreen) { + MaterialAlertDialogBuilder(requireContext()) + .setTitle(R.string.chapters) + .setItems(titles.toTypedArray()) { _, index -> + val position = chapters[index].start!! * 1000 + exoPlayer.seekTo(position) + } + .show() + } else { + toggleDescription() + } } setCurrentChapterName() }