-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #483 from VGJohn/long-press-redesign
Redesign the long press option in the fullscreen player
- Loading branch information
Showing
5 changed files
with
169 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...ayer/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/LongPressOptionsFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
modules/features/player/src/main/res/layout/fragment_long_press_options.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |