Update menus
Implement a "Go to artist" option in library albums, along with removing unneeded icons to reduce the space taken up by them.
This commit is contained in:
parent
4c1f009d93
commit
f109130fb8
8 changed files with 81 additions and 31 deletions
|
@ -14,7 +14,7 @@ import org.oxycblt.auxio.music.Artist
|
|||
import org.oxycblt.auxio.music.BaseModel
|
||||
import org.oxycblt.auxio.music.MusicStore
|
||||
import org.oxycblt.auxio.playback.state.PlaybackMode
|
||||
import org.oxycblt.auxio.ui.setupAlbumActions
|
||||
import org.oxycblt.auxio.ui.setupArtistAlbumActions
|
||||
|
||||
/**
|
||||
* The [DetailFragment] for an artist.
|
||||
|
@ -53,7 +53,7 @@ class ArtistDetailFragment : DetailFragment() {
|
|||
}
|
||||
},
|
||||
doOnLongClick = { data, view ->
|
||||
PopupMenu(requireContext(), view).setupAlbumActions(
|
||||
PopupMenu(requireContext(), view).setupArtistAlbumActions(
|
||||
requireContext(), data, playbackModel
|
||||
)
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ class LibraryFragment : Fragment(), SearchView.OnQueryTextListener {
|
|||
|
||||
when (data) {
|
||||
is Song -> menu.setupSongActions(requireContext(), data, playbackModel, detailModel)
|
||||
is Album -> menu.setupAlbumActions(requireContext(), data, playbackModel)
|
||||
is Album -> menu.setupAlbumActions(requireContext(), data, playbackModel, detailModel)
|
||||
is Artist -> menu.setupArtistActions(data, playbackModel)
|
||||
is Genre -> menu.setupGenreActions(data, playbackModel)
|
||||
|
||||
|
|
|
@ -188,21 +188,16 @@ fun PopupMenu.setupAlbumSongActions(
|
|||
* @param context [Context] required
|
||||
* @param album [Album] The menu should correspond to
|
||||
* @param playbackModel The [PlaybackViewModel] the menu should dispatch actions to.
|
||||
* @param detailModel The [DetailViewModel] the menu should dispatch actions to.
|
||||
*/
|
||||
fun PopupMenu.setupAlbumActions(
|
||||
context: Context,
|
||||
album: Album,
|
||||
playbackModel: PlaybackViewModel
|
||||
playbackModel: PlaybackViewModel,
|
||||
detailModel: DetailViewModel
|
||||
) {
|
||||
setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.action_queue_add -> {
|
||||
playbackModel.addToUserQueue(album)
|
||||
context.getString(R.string.label_queue_added).createToast(context)
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
R.id.action_play -> {
|
||||
playbackModel.playAlbum(album, false)
|
||||
true
|
||||
|
@ -213,12 +208,57 @@ fun PopupMenu.setupAlbumActions(
|
|||
true
|
||||
}
|
||||
|
||||
R.id.action_queue_add -> {
|
||||
playbackModel.addToUserQueue(album)
|
||||
context.getString(R.string.label_queue_added).createToast(context)
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
R.id.action_go_artist -> {
|
||||
detailModel.navToItem(album.artist)
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
inflateAndShow(R.menu.menu_album_actions)
|
||||
}
|
||||
|
||||
/**
|
||||
* Show actions for an [Album] in the artist detail fragment
|
||||
* @param context [Context] required
|
||||
* @param album [Album] The menu should correspond to
|
||||
* @param playbackModel The [PlaybackViewModel] the menu should dispatch actions to.
|
||||
*/
|
||||
fun PopupMenu.setupArtistAlbumActions(context: Context, album: Album, playbackModel: PlaybackViewModel) {
|
||||
setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.action_play -> {
|
||||
playbackModel.playAlbum(album, false)
|
||||
true
|
||||
}
|
||||
|
||||
R.id.action_shuffle -> {
|
||||
playbackModel.playAlbum(album, true)
|
||||
true
|
||||
}
|
||||
|
||||
R.id.action_queue_add -> {
|
||||
playbackModel.addToUserQueue(album)
|
||||
context.getString(R.string.label_queue_added).createToast(context)
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
inflateAndShow(R.menu.menu_artist_album_actions)
|
||||
}
|
||||
|
||||
/**
|
||||
* Show actions for an [Artist].
|
||||
* @param artist The [Artist] The menu should correspond to
|
||||
|
|
|
@ -3,17 +3,14 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_play"
|
||||
android:icon="@drawable/ic_play"
|
||||
android:title="@string/label_play"
|
||||
app:showAsAction="ifRoom" />
|
||||
android:title="@string/label_play" />
|
||||
<item
|
||||
android:id="@+id/action_shuffle"
|
||||
android:icon="@drawable/ic_shuffle"
|
||||
android:title="@string/label_shuffle"
|
||||
app:showAsAction="never" />
|
||||
android:title="@string/label_shuffle" />
|
||||
<item
|
||||
android:id="@+id/action_queue_add"
|
||||
android:icon="@drawable/ic_queue_add"
|
||||
android:title="@string/label_queue_add"
|
||||
app:showAsAction="never" />
|
||||
android:title="@string/label_queue_add" />
|
||||
<item
|
||||
android:id="@+id/action_go_artist"
|
||||
android:title="@string/label_go_artist" />
|
||||
</menu>
|
|
@ -2,14 +2,11 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_queue_add"
|
||||
android:icon="@drawable/ic_queue_add"
|
||||
android:title="@string/label_queue_add" />
|
||||
<item
|
||||
android:id="@+id/action_go_artist"
|
||||
android:icon="@drawable/ic_artist"
|
||||
android:title="@string/label_go_artist" />
|
||||
<item
|
||||
android:id="@+id/action_play_artist"
|
||||
android:icon="@drawable/ic_artist"
|
||||
android:title="@string/label_play_artist" />
|
||||
</menu>
|
|
@ -3,12 +3,8 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_play_albums"
|
||||
android:icon="@drawable/ic_play"
|
||||
android:title="@string/label_play"
|
||||
app:showAsAction="never" />
|
||||
android:title="@string/label_play" />
|
||||
<item
|
||||
android:id="@+id/action_shuffle"
|
||||
android:icon="@drawable/ic_shuffle"
|
||||
android:title="@string/label_shuffle"
|
||||
app:showAsAction="ifRoom" />
|
||||
android:title="@string/label_shuffle" />
|
||||
</menu>
|
19
app/src/main/res/menu/menu_artist_album_actions.xml
Normal file
19
app/src/main/res/menu/menu_artist_album_actions.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_play"
|
||||
android:icon="@drawable/ic_play"
|
||||
android:title="@string/label_play"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_shuffle"
|
||||
android:icon="@drawable/ic_shuffle"
|
||||
android:title="@string/label_shuffle"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_queue_add"
|
||||
android:icon="@drawable/ic_queue_add"
|
||||
android:title="@string/label_queue_add"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
|
@ -12,8 +12,9 @@
|
|||
tools:ignore="AlwaysShowAction" />
|
||||
|
||||
<!--
|
||||
Has to be always since android mangles this action when I make it invisible and then visible again
|
||||
I hate this platform so much
|
||||
This action has to be always shown since android mangles this action when I make it invisible
|
||||
and then visible again.
|
||||
I hate this platform so much.
|
||||
-->
|
||||
<item
|
||||
android:id="@+id/submenu_sorting"
|
||||
|
|
Loading…
Reference in a new issue