Fix bugs
Fix a ton of misc bugs that I stumbled upon.
This commit is contained in:
parent
51b2749c06
commit
21dbad7091
16 changed files with 118 additions and 83 deletions
|
@ -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,
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/album_toolbar"
|
||||
style="@style/Toolbar.Style.Icon"
|
||||
android:elevation="@dimen/elevation_normal"
|
||||
app:menu="@menu/menu_album_actions"
|
||||
app:title="@string/label_library" />
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/artist_toolbar"
|
||||
style="@style/Toolbar.Style.Icon"
|
||||
android:elevation="@dimen/elevation_normal"
|
||||
app:menu="@menu/menu_detail"
|
||||
app:title="@string/label_library" />
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/genre_toolbar"
|
||||
style="@style/Toolbar.Style.Icon"
|
||||
android:elevation="@dimen/elevation_normal"
|
||||
app:menu="@menu/menu_detail"
|
||||
app:title="@string/label_library" />
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/queue_toolbar"
|
||||
style="@style/Toolbar.Style.Icon"
|
||||
android:elevation="@dimen/elevation_normal"
|
||||
app:navigationIcon="@drawable/ic_down"
|
||||
app:title="@string/label_queue" />
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/song_toolbar"
|
||||
style="@style/Toolbar.Style"
|
||||
android:elevation="@dimen/elevation_normal"
|
||||
app:title="@string/setting_title" />
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/song_toolbar"
|
||||
style="@style/Toolbar.Style"
|
||||
android:elevation="@dimen/elevation_normal"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:menu="@menu/menu_songs"
|
||||
|
@ -39,7 +40,7 @@
|
|||
|
||||
<org.oxycblt.auxio.recycler.NoLeakThumbView
|
||||
android:id="@+id/song_fast_scroll_thumb"
|
||||
android:layout_width="50dp"
|
||||
android:layout_width="@dimen/width_thumb_view"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/song_fast_scroll"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
<!-- Width Namespace | Width for UI elements -->
|
||||
<dimen name="width_track_number">32dp</dimen>
|
||||
<dimen name="width_thumb_view">50dp</dimen>
|
||||
|
||||
<!-- Size Namespace | Width & Heights for UI elements -->
|
||||
<dimen name="size_error_icon">48dp</dimen>
|
||||
|
|
|
@ -26,21 +26,27 @@
|
|||
<style name="Toolbar.Style" parent="ThemeOverlay.MaterialComponents.ActionBar">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">?android:attr/actionBarSize</item>
|
||||
<item name="android:elevation">4dp</item>
|
||||
<item name="popupTheme">@style/AppThemeOverlay.ToolbarPopup</item>
|
||||
|
||||
<item name="popupTheme">@style/Widget.CustomPopup</item>
|
||||
<item name="titleTextAppearance">@style/TextAppearance.Toolbar.Header</item>
|
||||
</style>
|
||||
|
||||
<!-- Toolbar sub-style with a nav icon -->
|
||||
<style name="Toolbar.Style.Icon" parent="Toolbar.Style">
|
||||
<item name="navigationIcon">@drawable/ic_back</item>
|
||||
</style>
|
||||
|
||||
<!-- Toolbar sub theme with a fix for an odd search style -->
|
||||
<!-- Toolbar sub-style with a fix for an odd search style -->
|
||||
<style name="Toolbar.Style.Search" parent="Toolbar.Style">
|
||||
<item name="android:searchViewStyle">@style/Widget.AppCompat.SearchView</item>
|
||||
</style>
|
||||
|
||||
<!-- Toolbar popup menu -->
|
||||
<style name="AppThemeOverlay.ToolbarPopup" parent="ThemeOverlay.AppCompat.DayNight">
|
||||
<item name="android:colorBackground">@color/background</item>
|
||||
<item name="colorControlHighlight">@color/selection_color</item>
|
||||
</style>
|
||||
|
||||
<!-- Toolbar Title Theme -->
|
||||
<style name="TextAppearance.Toolbar.Header" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
|
||||
<item name="android:fontFamily">@font/inter_black</item>
|
||||
|
@ -62,7 +68,6 @@
|
|||
|
||||
<!-- Custom popup menu theme -->
|
||||
<style name="Widget.CustomPopup" parent="Widget.AppCompat.PopupMenu">
|
||||
<item name="android:colorBackground">@color/background</item>
|
||||
<item name="android:popupBackground">@color/background</item>
|
||||
<item name="colorControlHighlight">@color/selection_color</item>
|
||||
<item name="cornerRadius">0dp</item>
|
||||
|
@ -143,6 +148,7 @@
|
|||
<item name="android:background">@drawable/ui_header_dividers</item>
|
||||
</style>
|
||||
|
||||
<!-- Style for an action header -->
|
||||
<style name="HeaderAction">
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_width">0dp</item>
|
||||
|
|
Loading…
Reference in a new issue