Skip to content

Commit

Permalink
Merge pull request #483 from VGJohn/long-press-redesign
Browse files Browse the repository at this point in the history
Redesign the long press option in the fullscreen player
  • Loading branch information
ashiagr authored Oct 26, 2022
2 parents 39bfc9a + ca3eb2a commit 2402df8
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class PlayerHeaderFragment : BaseFragment(), PlayerClickListener {
}

override fun onSkipForwardLongPress() {
viewModel.longSkipForwardOptionsDialog().show(parentFragmentManager, "longpressoptions")
LongPressOptionsFragment().show(parentFragmentManager, "longpressoptions")
}

override fun onEffectsClick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/primary_ui_01"
android:theme="@style/PlayerTheme">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="24dp">

<androidx.constraintlayout.widget.Group
android:id="@+id/markPlayed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="labelMarkPlayed,buttonMarkPlayed"
tools:ignore="MissingConstraints" />

<androidx.constraintlayout.widget.Group
android:id="@+id/nextEpisode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="separator1,labelNextEpisode,buttonNextEpisode"
tools:ignore="MissingConstraints" />

<View
android:layout_width="48dp"
android:layout_height="4dp"
android:layout_marginTop="4dp"
android:background="@drawable/background_dragger_player"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/labelMarkPlayed"
style="@style/DarkSubtitle1"
android:layout_width="wrap_content"
android:layout_height="64dp"
android:layout_marginStart="32dp"
android:layout_marginTop="24dp"
android:gravity="center_vertical"
android:importantForAccessibility="no"
android:text="@string/mark_played"
android:textColor="?attr/player_contrast_01"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<View
android:id="@+id/buttonMarkPlayed"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:contentDescription="@string/mark_played"
android:focusable="true"
app:layout_constraintBottom_toBottomOf="@+id/labelMarkPlayed"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/labelMarkPlayed" />

<View
android:id="@+id/separator1"
android:layout_width="0dp"
android:layout_height="@dimen/divider_height"
android:background="?attr/player_contrast_05"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/labelMarkPlayed" />

<TextView
android:id="@+id/labelNextEpisode"
style="@style/DarkSubtitle1"
android:layout_width="wrap_content"
android:layout_height="64dp"
android:layout_marginStart="32dp"
android:gravity="center_vertical"
android:importantForAccessibility="no"
android:text="@string/next_episode"
android:textColor="?attr/player_contrast_01"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/separator1" />

<View
android:id="@+id/buttonNextEpisode"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:contentDescription="@string/next_episode"
android:focusable="true"
app:layout_constraintBottom_toBottomOf="@+id/labelNextEpisode"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/labelNextEpisode" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.core.widget.NestedScrollView>

0 comments on commit 2402df8

Please sign in to comment.