From 8afbc32a05f8a206564922d8a64ae83e47e811a4 Mon Sep 17 00:00:00 2001 From: VGJohn Date: Tue, 25 Oct 2022 05:30:00 +0100 Subject: [PATCH 1/2] Redesigned the long press option in the fullscreen player --- .../player/view/LongPressOptionsFragment.kt | 54 ++++++++++ .../player/view/PlayerHeaderFragment.kt | 2 +- .../player/viewmodel/PlayerViewModel.kt | 23 ++-- .../layout/fragment_long_press_options.xml | 102 ++++++++++++++++++ 4 files changed, 167 insertions(+), 14 deletions(-) create mode 100644 modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/LongPressOptionsFragment.kt create mode 100644 modules/features/player/src/main/res/layout/fragment_long_press_options.xml diff --git a/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/LongPressOptionsFragment.kt b/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/LongPressOptionsFragment.kt new file mode 100644 index 00000000000..3fbf3b340b1 --- /dev/null +++ b/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/LongPressOptionsFragment.kt @@ -0,0 +1,54 @@ +package au.com.shiftyjelly.pocketcasts.player.view + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.core.view.isVisible +import androidx.fragment.app.activityViewModels +import au.com.shiftyjelly.pocketcasts.player.databinding.FragmentLongPressOptionsBinding +import au.com.shiftyjelly.pocketcasts.player.viewmodel.PlayerViewModel +import au.com.shiftyjelly.pocketcasts.ui.helper.StatusBarColor +import au.com.shiftyjelly.pocketcasts.views.extensions.applyColor +import au.com.shiftyjelly.pocketcasts.views.fragments.BaseDialogFragment +import com.google.android.material.bottomsheet.BottomSheetBehavior +import com.google.android.material.bottomsheet.BottomSheetDialog +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class LongPressOptionsFragment : BaseDialogFragment() { + + override val statusBarColor: StatusBarColor? = null + + private val viewModel: PlayerViewModel by activityViewModels() + private var binding: FragmentLongPressOptionsBinding? = null + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { + val binding = FragmentLongPressOptionsBinding.inflate(inflater, container, false) + this.binding = binding + + binding.buttonMarkPlayed.setOnClickListener { + viewModel.onMarkAsPlayedClick() + dismiss() + } + binding.buttonNextEpisode.setOnClickListener { + viewModel.onNextEpisodeClick() + dismiss() + } + + binding.nextEpisode.isVisible = viewModel.hasNextEpisode() + + return binding.root + } + + @Suppress("DEPRECATION") + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + + viewModel.playingEpisodeLive.observe(viewLifecycleOwner) { (_, backgroundColor) -> + applyColor(theme, backgroundColor) + } + + (dialog as? BottomSheetDialog)?.behavior?.state = BottomSheetBehavior.STATE_EXPANDED + } +} diff --git a/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/PlayerHeaderFragment.kt b/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/PlayerHeaderFragment.kt index 5e454225c6d..db7a07c4d3a 100644 --- a/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/PlayerHeaderFragment.kt +++ b/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/PlayerHeaderFragment.kt @@ -436,7 +436,7 @@ class PlayerHeaderFragment : BaseFragment(), PlayerClickListener { } override fun onSkipForwardLongPress() { - viewModel.longSkipForwardOptionsDialog().show(parentFragmentManager, "longpressoptions") + LongPressOptionsFragment().show(parentFragmentManager, "longpressoptions") } override fun onEffectsClick() { diff --git a/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/viewmodel/PlayerViewModel.kt b/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/viewmodel/PlayerViewModel.kt index 5adb60369e0..fdc85553517 100644 --- a/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/viewmodel/PlayerViewModel.kt +++ b/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/viewmodel/PlayerViewModel.kt @@ -39,7 +39,6 @@ import au.com.shiftyjelly.pocketcasts.ui.theme.Theme import au.com.shiftyjelly.pocketcasts.utils.Util import au.com.shiftyjelly.pocketcasts.utils.log.LogBuffer import au.com.shiftyjelly.pocketcasts.views.dialog.ConfirmationDialog -import au.com.shiftyjelly.pocketcasts.views.dialog.OptionsDialog import au.com.shiftyjelly.pocketcasts.views.helper.CloudDeleteHelper import au.com.shiftyjelly.pocketcasts.views.helper.DeleteState import com.jakewharton.rxrelay2.BehaviorRelay @@ -387,20 +386,18 @@ class PlayerViewModel @Inject constructor( playbackManager.skipForward(playbackSource = playbackSource) } - fun longSkipForwardOptionsDialog(): OptionsDialog { - var optionsDialogBuilder = OptionsDialog().setForceDarkTheme(true) - optionsDialogBuilder = optionsDialogBuilder.addTextOption(titleId = LR.string.mark_played) { - playbackManager.upNextQueue.currentEpisode?.let { - markAsPlayedConfirmed(it) - } - } - if (playbackManager.upNextQueue.queueEpisodes.isNotEmpty()) { - optionsDialogBuilder = optionsDialogBuilder.addTextOption(titleId = LR.string.next_episode) { - playbackManager.playNextInQueue(playbackSource = playbackSource) - } + fun onMarkAsPlayedClick() { + playbackManager.upNextQueue.currentEpisode?.let { + markAsPlayedConfirmed(it) } + } + + fun hasNextEpisode(): Boolean { + return playbackManager.upNextQueue.queueEpisodes.isNotEmpty() + } - return optionsDialogBuilder + fun onNextEpisodeClick() { + playbackManager.playNextInQueue(playbackSource = playbackSource) } private fun markAsPlayedConfirmed(episode: Playable) { diff --git a/modules/features/player/src/main/res/layout/fragment_long_press_options.xml b/modules/features/player/src/main/res/layout/fragment_long_press_options.xml new file mode 100644 index 00000000000..ffed29a721a --- /dev/null +++ b/modules/features/player/src/main/res/layout/fragment_long_press_options.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From ca3eb2afc34328668aa2d34e0a10b452c99444a6 Mon Sep 17 00:00:00 2001 From: VGJohn Date: Tue, 25 Oct 2022 05:33:49 +0100 Subject: [PATCH 2/2] Added changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c13ee552565..1e8f4c4436a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ ([#482](https://github.com/Automattic/pocket-casts-android/pull/482)). * Redesign of the fullscreen player share option ([#451](https://github.com/Automattic/pocket-casts-android/pull/451)). + * Redesign of the fullscreen player long press option + ([#483](https://github.com/Automattic/pocket-casts-android/pull/483)). * Bug Fixes: * Fixed Help & Feedback buttons being hidden when using text zoom. ([#446](https://github.com/Automattic/pocket-casts-android/pull/446)).