Fix bugs
Fix a ton of misc bugs that I stumbled upon.
This commit is contained in:
@@ -71,6 +71,8 @@ class MainFragment : Fragment() {
|
||||
|
||||
binding.lifecycleOwner = this
|
||||
|
||||
handleCompactPlaybackVisibility(binding, playbackModel.song.value)
|
||||
|
||||
binding.navBar.itemIconTintList = navTints
|
||||
binding.navBar.itemTextColor = navTints
|
||||
|
||||
@@ -84,17 +86,7 @@ class MainFragment : Fragment() {
|
||||
|
||||
// Change CompactPlaybackFragment's visibility here so that an animation occurs.
|
||||
playbackModel.song.observe(viewLifecycleOwner) {
|
||||
if (it == null) {
|
||||
Log.d(
|
||||
this::class.simpleName,
|
||||
"Hiding CompactPlaybackFragment since no song is being played."
|
||||
)
|
||||
|
||||
binding.compactPlayback.visibility = View.GONE
|
||||
playbackModel.disableAnimation()
|
||||
} else {
|
||||
binding.compactPlayback.visibility = View.VISIBLE
|
||||
}
|
||||
handleCompactPlaybackVisibility(binding, it)
|
||||
}
|
||||
|
||||
playbackModel.navToItem.observe(viewLifecycleOwner) {
|
||||
@@ -161,8 +153,20 @@ class MainFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
private fun handleCompactPlaybackVisibility(binding: FragmentMainBinding, song: Song?) {
|
||||
if (song == null) {
|
||||
Log.d(
|
||||
this::class.simpleName,
|
||||
"Hiding CompactPlaybackFragment since no song is being played."
|
||||
)
|
||||
|
||||
binding.compactPlayback.visibility = View.GONE
|
||||
playbackModel.disableAnimation()
|
||||
} else {
|
||||
binding.compactPlayback.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,21 +73,30 @@ class AlbumDetailFragment : DetailFragment() {
|
||||
|
||||
setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.action_shuffle -> playbackModel.playAlbum(
|
||||
detailModel.currentAlbum.value!!,
|
||||
R.id.action_shuffle -> {
|
||||
playbackModel.playAlbum(
|
||||
detailModel.currentAlbum.value!!, true
|
||||
)
|
||||
|
||||
true
|
||||
)
|
||||
R.id.action_play -> playbackModel.playAlbum(
|
||||
detailModel.currentAlbum.value!!, false
|
||||
)
|
||||
}
|
||||
R.id.action_play -> {
|
||||
playbackModel.playAlbum(
|
||||
detailModel.currentAlbum.value!!, false
|
||||
)
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
R.id.action_queue_add -> {
|
||||
playbackModel.addToUserQueue(detailModel.currentAlbum.value!!)
|
||||
context.getString(R.string.label_queue_added).createToast(requireContext())
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,16 +76,24 @@ class ArtistDetailFragment : DetailFragment() {
|
||||
|
||||
setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.action_shuffle -> playbackModel.playArtist(
|
||||
detailModel.currentArtist.value!!,
|
||||
true
|
||||
)
|
||||
R.id.action_play -> playbackModel.playArtist(
|
||||
detailModel.currentArtist.value!!, false
|
||||
)
|
||||
}
|
||||
R.id.action_shuffle -> {
|
||||
playbackModel.playArtist(
|
||||
detailModel.currentArtist.value!!,
|
||||
true
|
||||
)
|
||||
|
||||
true
|
||||
true
|
||||
}
|
||||
R.id.action_play -> {
|
||||
playbackModel.playArtist(
|
||||
detailModel.currentArtist.value!!, false
|
||||
)
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,16 +75,24 @@ class GenreDetailFragment : DetailFragment() {
|
||||
|
||||
setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.action_shuffle -> playbackModel.playGenre(
|
||||
detailModel.currentGenre.value!!,
|
||||
true
|
||||
)
|
||||
R.id.action_play -> playbackModel.playGenre(
|
||||
detailModel.currentGenre.value!!, false
|
||||
)
|
||||
}
|
||||
R.id.action_shuffle -> {
|
||||
playbackModel.playGenre(
|
||||
detailModel.currentGenre.value!!,
|
||||
true
|
||||
)
|
||||
|
||||
true
|
||||
true
|
||||
}
|
||||
R.id.action_play -> {
|
||||
playbackModel.playGenre(
|
||||
detailModel.currentGenre.value!!, false
|
||||
)
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ class LibraryFragment : Fragment(), SearchView.OnQueryTextListener {
|
||||
)
|
||||
it.expandActionView()
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
@@ -75,9 +75,9 @@ class PlaybackFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
|
||||
setOnMenuItemClickListener {
|
||||
if (it.itemId == R.id.action_queue) {
|
||||
findNavController().navigate(PlaybackFragmentDirections.actionShowQueue())
|
||||
}
|
||||
|
||||
true
|
||||
true
|
||||
} else false
|
||||
}
|
||||
|
||||
queueMenuItem = menu.findItem(R.id.action_queue)
|
||||
|
||||
@@ -107,7 +107,6 @@ class SettingsListFragment : PreferenceFragmentCompat() {
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: Implement dialog edge-to-edge
|
||||
layoutManager = LinearLayoutManager(
|
||||
requireContext()
|
||||
).also { it.orientation = LinearLayoutManager.HORIZONTAL }
|
||||
|
||||
@@ -6,7 +6,6 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@@ -24,7 +23,7 @@ import org.oxycblt.auxio.ui.setupSongActions
|
||||
* them.
|
||||
* @author OxygenCobalt
|
||||
*/
|
||||
class SongsFragment : Fragment(), SearchView.OnQueryTextListener {
|
||||
class SongsFragment : Fragment() {
|
||||
private val playbackModel: PlaybackViewModel by activityViewModels()
|
||||
|
||||
override fun onCreateView(
|
||||
@@ -52,8 +51,9 @@ class SongsFragment : Fragment(), SearchView.OnQueryTextListener {
|
||||
setOnMenuItemClickListener {
|
||||
if (it.itemId == R.id.action_shuffle) {
|
||||
playbackModel.shuffleAll()
|
||||
}
|
||||
true
|
||||
|
||||
true
|
||||
} else false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,28 +69,16 @@ class SongsFragment : Fragment(), SearchView.OnQueryTextListener {
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onQueryTextChange(newText: String?): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onQueryTextSubmit(query: String?): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
private fun setupFastScroller(binding: FragmentSongsBinding) {
|
||||
val musicStore = MusicStore.getInstance()
|
||||
|
||||
binding.songFastScroll.apply {
|
||||
var hasAddedNumber = false
|
||||
var iters = 0
|
||||
|
||||
// TODO: Do selection instead of using iters
|
||||
|
||||
setupWithRecyclerView(
|
||||
binding.songRecycler,
|
||||
{ pos ->
|
||||
val item = musicStore.songs[pos]
|
||||
iters++
|
||||
|
||||
// If the item starts with "the"/"a", then actually use the character after that
|
||||
// as its initial. Yes, this is stupidly western-centric but the code [hopefully]
|
||||
@@ -108,31 +96,36 @@ class SongsFragment : Fragment(), SearchView.OnQueryTextListener {
|
||||
item.name[0].toUpperCase()
|
||||
}
|
||||
|
||||
// Check if this song starts with a number, if so, then concat it with a single
|
||||
// "Numeric" item if haven't already.
|
||||
// This check only occurs on the second time the fast scroller is polled for items.
|
||||
if (iters >= musicStore.songs.size) {
|
||||
if (char.isDigit()) {
|
||||
if (!hasAddedNumber) {
|
||||
hasAddedNumber = true
|
||||
|
||||
return@setupWithRecyclerView FastScrollItemIndicator.Text("#")
|
||||
} else {
|
||||
return@setupWithRecyclerView null
|
||||
}
|
||||
}
|
||||
// Use "#" if the character is a digit.
|
||||
if (char.isDigit()) {
|
||||
FastScrollItemIndicator.Text("#")
|
||||
} else {
|
||||
FastScrollItemIndicator.Text(char.toString())
|
||||
}
|
||||
|
||||
FastScrollItemIndicator.Text(
|
||||
char.toString()
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
showIndicator = { indicator, _, _ ->
|
||||
var isGood = true
|
||||
|
||||
// Remove all but the first "#" character
|
||||
if (indicator is FastScrollItemIndicator.Text) {
|
||||
if (indicator.text == "#") {
|
||||
if (hasAddedNumber) {
|
||||
isGood = false
|
||||
}
|
||||
|
||||
hasAddedNumber = true
|
||||
}
|
||||
}
|
||||
|
||||
isGood
|
||||
}
|
||||
|
||||
useDefaultScroller = false
|
||||
|
||||
itemIndicatorSelectedCallbacks.add(object :
|
||||
FastScrollerView.ItemIndicatorSelectedCallback {
|
||||
itemIndicatorSelectedCallbacks.add(
|
||||
object : FastScrollerView.ItemIndicatorSelectedCallback {
|
||||
override fun onItemIndicatorSelected(
|
||||
indicator: FastScrollItemIndicator,
|
||||
indicatorCenterY: Int,
|
||||
|
||||
Reference in New Issue
Block a user