diff --git a/README.md b/README.md
index 4f67749de..49bd4f1d5 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ Auxio is a local music player with a fast, reliable UI/UX without the many usele
I primarily built Auxio for myself, but you can use it too, I guess.
-**This branch is the development version of the repository. For a stable version, see the master branch.**
+**The default branch is the development version of the repository. For a stable version, see the master branch.**
## Screenshots
diff --git a/app/src/main/java/org/oxycblt/auxio/detail/AlbumDetailFragment.kt b/app/src/main/java/org/oxycblt/auxio/detail/AlbumDetailFragment.kt
index c3e315fa4..59e4d63a4 100644
--- a/app/src/main/java/org/oxycblt/auxio/detail/AlbumDetailFragment.kt
+++ b/app/src/main/java/org/oxycblt/auxio/detail/AlbumDetailFragment.kt
@@ -23,10 +23,12 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.core.view.children
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import androidx.recyclerview.widget.LinearSmoothScroller
import org.oxycblt.auxio.R
+import org.oxycblt.auxio.databinding.FragmentDetailBinding
import org.oxycblt.auxio.detail.recycler.AlbumDetailAdapter
import org.oxycblt.auxio.music.ActionHeader
import org.oxycblt.auxio.music.Album
@@ -43,6 +45,8 @@ import org.oxycblt.auxio.util.showToast
/**
* The [DetailFragment] for an album.
* @author OxygenCobalt
+ * TODO: Disable queue adding when there is no playback here too, however make it so that
+ * it updates when the song changes.
*/
class AlbumDetailFragment : DetailFragment() {
private val args: AlbumDetailFragmentArgs by navArgs()
@@ -65,12 +69,20 @@ class AlbumDetailFragment : DetailFragment() {
binding.lifecycleOwner = viewLifecycleOwner
setupToolbar(detailModel.curAlbum.value!!, R.menu.menu_album_detail) { itemId ->
- if (itemId == R.id.action_queue_add) {
- playbackModel.playNext(detailModel.curAlbum.value!!)
- requireContext().showToast(R.string.lbl_queue_added)
- true
- } else {
- false
+ when (itemId) {
+ R.id.action_play_next -> {
+ playbackModel.playNext(detailModel.curAlbum.value!!)
+ requireContext().showToast(R.string.lbl_queue_added)
+ true
+ }
+
+ R.id.action_queue_add -> {
+ playbackModel.addToQueue(detailModel.curAlbum.value!!)
+ requireContext().showToast(R.string.lbl_queue_added)
+ true
+ }
+
+ else -> false
}
}
@@ -79,6 +91,8 @@ class AlbumDetailFragment : DetailFragment() {
item is Header || item is ActionHeader || item is Album
}
+ updateQueueActions(playbackModel.song.value, binding)
+
// -- DETAILVIEWMODEL SETUP ---
detailModel.albumData.observe(viewLifecycleOwner) { data ->
@@ -137,6 +151,8 @@ class AlbumDetailFragment : DetailFragment() {
// --- PLAYBACKVIEWMODEL SETUP ---
playbackModel.song.observe(viewLifecycleOwner) { song ->
+ updateQueueActions(song, binding)
+
if (playbackModel.playbackMode.value == PlaybackMode.IN_ALBUM &&
playbackModel.parent.value?.id == detailModel.curAlbum.value!!.id
) {
@@ -152,6 +168,17 @@ class AlbumDetailFragment : DetailFragment() {
return binding.root
}
+ /**
+ * Updates the queue actions when
+ */
+ private fun updateQueueActions(song: Song?, binding: FragmentDetailBinding) {
+ for (item in binding.detailToolbar.menu.children) {
+ if (item.itemId == R.id.action_play_next || item.itemId == R.id.action_queue_add) {
+ item.isEnabled = song != null
+ }
+ }
+ }
+
/**
* Scroll to an song using its [id].
*/
diff --git a/app/src/main/java/org/oxycblt/auxio/detail/DetailFragment.kt b/app/src/main/java/org/oxycblt/auxio/detail/DetailFragment.kt
index 7e67f1043..488db065d 100644
--- a/app/src/main/java/org/oxycblt/auxio/detail/DetailFragment.kt
+++ b/app/src/main/java/org/oxycblt/auxio/detail/DetailFragment.kt
@@ -57,19 +57,19 @@ abstract class DetailFragment : Fragment() {
/**
* Shortcut method for doing setup of the detail toolbar.
* @param data Parent data to use as the toolbar title
- * @param menu Menu resource to use
+ * @param menuId Menu resource to use
* @param onMenuClick (Optional) a click listener for that menu
*/
protected fun setupToolbar(
data: MusicParent,
- @MenuRes menu: Int = -1,
+ @MenuRes menuId: Int = -1,
onMenuClick: ((itemId: Int) -> Boolean)? = null
) {
binding.detailToolbar.apply {
title = data.resolvedName
- if (menu != -1) {
- inflateMenu(menu)
+ if (menuId != -1) {
+ inflateMenu(menuId)
}
setNavigationOnClickListener {
diff --git a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackViewModel.kt b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackViewModel.kt
index 361aa7c0d..a741adafe 100644
--- a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackViewModel.kt
+++ b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackViewModel.kt
@@ -214,8 +214,9 @@ class PlaybackViewModel : ViewModel(), PlaybackStateManager.Callback {
*/
fun removeQueueDataItem(adapterIndex: Int, apply: () -> Unit) {
val adjusted = adapterIndex + (playbackManager.queue.size - mNextUp.value!!.size)
+ logD("$adjusted")
- if (adjusted in mNextUp.value!!.indices) {
+ if (adjusted in playbackManager.queue.indices) {
apply()
playbackManager.removeQueueItem(adjusted)
}
@@ -230,7 +231,7 @@ class PlaybackViewModel : ViewModel(), PlaybackStateManager.Callback {
val from = adapterFrom + delta
val to = adapterTo + delta
- if (from in mNextUp.value!!.indices && to in mNextUp.value!!.indices) {
+ if (from in playbackManager.queue.indices && to in playbackManager.queue.indices) {
apply()
playbackManager.moveQueueItems(from, to)
return true
diff --git a/app/src/main/java/org/oxycblt/auxio/ui/ActionMenu.kt b/app/src/main/java/org/oxycblt/auxio/ui/ActionMenu.kt
index 8915c35b0..99a831e2b 100644
--- a/app/src/main/java/org/oxycblt/auxio/ui/ActionMenu.kt
+++ b/app/src/main/java/org/oxycblt/auxio/ui/ActionMenu.kt
@@ -23,6 +23,7 @@ import androidx.annotation.IdRes
import androidx.annotation.MenuRes
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.PopupMenu
+import androidx.core.view.children
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import org.oxycblt.auxio.R
@@ -82,9 +83,11 @@ class ActionMenu(
inflate(menuRes)
// Disable any queue options if we don't have anything playing.
- val queueEnabled = playbackModel.song.value != null
- menu.findItem(R.id.action_play_next)?.isEnabled = queueEnabled
- menu.findItem(R.id.action_queue_add)?.isEnabled = queueEnabled
+ for (item in menu.children) {
+ if (item.itemId == R.id.action_play_next || item.itemId == R.id.action_queue_add) {
+ item.isEnabled = playbackModel.song.value != null
+ }
+ }
setOnMenuItemClickListener { item ->
onMenuClick(item.itemId)
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 5ce35f11a..8ccb2373e 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -23,7 +23,7 @@
排序方式
名称
艺术家
- 专辑/string>
+ 专辑
年份
首字符(正序)
@@ -169,12 +169,10 @@
已加载 %d 首曲目
- - %d 首歌曲
- - %d 首歌曲
+ - "%d 首歌曲"
- - %d 张专辑
- - %d 张专辑
+ - "%d 张专辑"