playback: add song menu option to names

Re-add the song menu option to the title section of the playback view.

This is again, due to the addition of the equalizer button, but also to
make this menu easier to reach.
This commit is contained in:
OxygenCobalt 2022-08-11 12:28:00 -06:00
parent d4884cc9ca
commit bb9c842154
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
7 changed files with 51 additions and 25 deletions

View file

@ -27,16 +27,13 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import org.oxycblt.auxio.R import org.oxycblt.auxio.R
import org.oxycblt.auxio.databinding.FragmentPlaybackPanelBinding import org.oxycblt.auxio.databinding.FragmentPlaybackPanelBinding
import org.oxycblt.auxio.music.MusicParent import org.oxycblt.auxio.music.MusicParent
import org.oxycblt.auxio.music.Song import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.playback.state.RepeatMode import org.oxycblt.auxio.playback.state.RepeatMode
import org.oxycblt.auxio.ui.MainNavigationAction import org.oxycblt.auxio.ui.MainNavigationAction
import org.oxycblt.auxio.ui.NavigationViewModel import org.oxycblt.auxio.ui.fragment.MenuFragment
import org.oxycblt.auxio.ui.fragment.ViewBindingFragment
import org.oxycblt.auxio.util.androidActivityViewModels
import org.oxycblt.auxio.util.collectImmediately import org.oxycblt.auxio.util.collectImmediately
import org.oxycblt.auxio.util.showToast import org.oxycblt.auxio.util.showToast
import org.oxycblt.auxio.util.systemBarInsetsCompat import org.oxycblt.auxio.util.systemBarInsetsCompat
@ -49,13 +46,11 @@ import org.oxycblt.auxio.util.systemBarInsetsCompat
* TODO: Make seek thumb grow when selected * TODO: Make seek thumb grow when selected
*/ */
class PlaybackPanelFragment : class PlaybackPanelFragment :
ViewBindingFragment<FragmentPlaybackPanelBinding>(), MenuFragment<FragmentPlaybackPanelBinding>(),
StyledSeekBar.Callback, StyledSeekBar.Callback,
Toolbar.OnMenuItemClickListener { Toolbar.OnMenuItemClickListener {
private val playbackModel: PlaybackViewModel by androidActivityViewModels()
private val navModel: NavigationViewModel by activityViewModels()
// AudioEffect expects you to use startActivityForResult with the panel intent. Use // AudioEffect expects you to use startActivityFoResult with the panel intent. Use
// the contract analogue for this since there is no built-in contract for AudioEffect. // the contract analogue for this since there is no built-in contract for AudioEffect.
private val activityLauncher by lifecycleObject { private val activityLauncher by lifecycleObject {
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
@ -97,6 +92,12 @@ class PlaybackPanelFragment :
playbackModel.song.value?.let { navModel.exploreNavigateTo(it.album) } playbackModel.song.value?.let { navModel.exploreNavigateTo(it.album) }
} }
binding.playbackSongMenu?.setOnClickListener { view ->
playbackModel.song.value?.let { song ->
musicMenu(view, R.menu.menu_playback_song_actions, song)
}
}
binding.playbackSeekBar.callback = this binding.playbackSeekBar.callback = this
binding.playbackRepeat.setOnClickListener { playbackModel.incrementRepeatMode() } binding.playbackRepeat.setOnClickListener { playbackModel.incrementRepeatMode() }

View file

@ -24,17 +24,17 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/playback_toolbar" app:layout_constraintTop_toBottomOf="@+id/playback_toolbar"
tools:staticIcon="@drawable/ic_song_48" /> tools:staticIcon="@drawable/ic_song_24" />
<TextView <TextView
android:id="@+id/playback_song" android:id="@+id/playback_song"
style="@style/Widget.Auxio.TextView.Primary" style="@style/Widget.Auxio.TextView.Primary"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_medium" android:layout_marginStart="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_medium" android:layout_marginEnd="@dimen/spacing_mid_medium"
app:layout_constraintBottom_toTopOf="@+id/playback_artist" app:layout_constraintBottom_toTopOf="@+id/playback_artist"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toStartOf="@+id/playback_song_menu"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_chainStyle="packed" app:layout_constraintVertical_chainStyle="packed"
tools:text="Song Name" /> tools:text="Song Name" />
@ -42,27 +42,39 @@
<TextView <TextView
android:id="@+id/playback_artist" android:id="@+id/playback_artist"
style="@style/Widget.Auxio.TextView.Secondary" style="@style/Widget.Auxio.TextView.Secondary"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_medium" android:layout_marginStart="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_medium" android:layout_marginEnd="@dimen/spacing_mid_medium"
app:layout_constraintBottom_toTopOf="@+id/playback_album" app:layout_constraintBottom_toTopOf="@+id/playback_album"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toStartOf="@+id/playback_song_menu"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
tools:text="Artist Name" /> tools:text="Artist Name" />
<TextView <TextView
android:id="@+id/playback_album" android:id="@+id/playback_album"
style="@style/Widget.Auxio.TextView.Secondary" style="@style/Widget.Auxio.TextView.Secondary"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_medium" android:layout_marginStart="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_medium" android:layout_marginEnd="@dimen/spacing_mid_medium"
app:layout_constraintBottom_toTopOf="@+id/playback_seek_bar" app:layout_constraintBottom_toTopOf="@+id/playback_seek_bar"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toStartOf="@+id/playback_song_menu"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
tools:text="Album Name" /> tools:text="Album Name" />
<Button
android:id="@+id/playback_song_menu"
style="@style/Widget.Auxio.Button.Icon.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:icon="@drawable/ic_more_24"
android:layout_marginEnd="@dimen/spacing_mid_medium"
app:layout_constraintBottom_toBottomOf="@+id/playback_album"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/playback_song" />
<org.oxycblt.auxio.playback.StyledSeekBar <org.oxycblt.auxio.playback.StyledSeekBar
android:id="@+id/playback_seek_bar" android:id="@+id/playback_seek_bar"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -24,8 +24,7 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/playback_toolbar" app:layout_constraintTop_toBottomOf="@+id/playback_toolbar"
app:layout_constraintVertical_bias="0.565" tools:staticIcon="@drawable/ic_song_24" />
tools:staticIcon="@drawable/ic_song_48" />
<TextView <TextView
android:id="@+id/playback_song" android:id="@+id/playback_song"

View file

@ -25,7 +25,7 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/playback_toolbar" app:layout_constraintTop_toBottomOf="@+id/playback_toolbar"
app:layout_constraintVertical_chainStyle="packed" app:layout_constraintVertical_chainStyle="packed"
tools:staticIcon="@drawable/ic_song_48" /> tools:staticIcon="@drawable/ic_song_24" />
<!-- TextView is wrapped in a container so that marquee doesn't break --> <!-- TextView is wrapped in a container so that marquee doesn't break -->

View file

@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:transitionGroup="true" android:transitionGroup="true"
android:background="?attr/colorSurface" android:background="?attr/colorSurface"
android:orientation="vertical"> android:orientation="vertical">
@ -28,6 +29,7 @@
android:name="org.oxycblt.auxio.settings.SettingsListFragment" android:name="org.oxycblt.auxio.settings.SettingsListFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" /> app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:layout="@android:layout/preference_category" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -47,7 +47,7 @@
style="@style/Widget.Auxio.TextView.Item.Primary" style="@style/Widget.Auxio.TextView.Item.Primary"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/spacing_medium" android:layout_marginEnd="@dimen/spacing_mid_medium"
android:textColor="@color/sel_toggleable_primary" android:textColor="@color/sel_toggleable_primary"
app:layout_constraintBottom_toTopOf="@+id/song_info" app:layout_constraintBottom_toTopOf="@+id/song_info"
app:layout_constraintEnd_toStartOf="@+id/song_drag_handle" app:layout_constraintEnd_toStartOf="@+id/song_drag_handle"
@ -61,7 +61,7 @@
style="@style/Widget.Auxio.TextView.Item.Secondary" style="@style/Widget.Auxio.TextView.Item.Secondary"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/spacing_medium" android:layout_marginEnd="@dimen/spacing_mid_medium"
android:textColor="@color/sel_toggleable_secondary" android:textColor="@color/sel_toggleable_secondary"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/song_drag_handle" app:layout_constraintEnd_toStartOf="@+id/song_drag_handle"
@ -74,7 +74,7 @@
style="@style/Widget.Auxio.Button.Icon.Small" style="@style/Widget.Auxio.Button.Icon.Small"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/spacing_small" android:layout_marginEnd="@dimen/spacing_mid_medium"
android:contentDescription="@string/desc_queue_handle" android:contentDescription="@string/desc_queue_handle"
app:icon="@drawable/ic_handle_24" app:icon="@drawable/ic_handle_24"
app:layout_constraintBottom_toBottomOf="@+id/song_album_cover" app:layout_constraintBottom_toBottomOf="@+id/song_album_cover"

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_go_artist"
android:title="@string/lbl_go_artist" />
<item
android:id="@+id/action_go_album"
android:title="@string/lbl_go_album" />
<item
android:id="@+id/action_song_detail"
android:title="@string/lbl_song_detail" />
</menu>