Fix a ton of misc bugs that I stumbled upon.
This commit is contained in:
OxygenCobalt 2020-12-02 20:02:59 -07:00
parent 51b2749c06
commit 21dbad7091
16 changed files with 118 additions and 83 deletions

View file

@ -71,6 +71,8 @@ class MainFragment : Fragment() {
binding.lifecycleOwner = this binding.lifecycleOwner = this
handleCompactPlaybackVisibility(binding, playbackModel.song.value)
binding.navBar.itemIconTintList = navTints binding.navBar.itemIconTintList = navTints
binding.navBar.itemTextColor = navTints binding.navBar.itemTextColor = navTints
@ -84,17 +86,7 @@ class MainFragment : Fragment() {
// Change CompactPlaybackFragment's visibility here so that an animation occurs. // Change CompactPlaybackFragment's visibility here so that an animation occurs.
playbackModel.song.observe(viewLifecycleOwner) { playbackModel.song.observe(viewLifecycleOwner) {
if (it == null) { handleCompactPlaybackVisibility(binding, it)
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
}
} }
playbackModel.navToItem.observe(viewLifecycleOwner) { playbackModel.navToItem.observe(viewLifecycleOwner) {
@ -161,8 +153,20 @@ class MainFragment : Fragment() {
} }
} }
//
return false 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
}
}
} }

View file

@ -73,21 +73,30 @@ class AlbumDetailFragment : DetailFragment() {
setOnMenuItemClickListener { setOnMenuItemClickListener {
when (it.itemId) { when (it.itemId) {
R.id.action_shuffle -> playbackModel.playAlbum( R.id.action_shuffle -> {
detailModel.currentAlbum.value!!, playbackModel.playAlbum(
detailModel.currentAlbum.value!!, true
)
true true
) }
R.id.action_play -> playbackModel.playAlbum( R.id.action_play -> {
detailModel.currentAlbum.value!!, false playbackModel.playAlbum(
) detailModel.currentAlbum.value!!, false
)
true
}
R.id.action_queue_add -> { R.id.action_queue_add -> {
playbackModel.addToUserQueue(detailModel.currentAlbum.value!!) playbackModel.addToUserQueue(detailModel.currentAlbum.value!!)
context.getString(R.string.label_queue_added).createToast(requireContext()) context.getString(R.string.label_queue_added).createToast(requireContext())
}
}
true true
}
else -> false
}
} }
} }

View file

@ -76,16 +76,24 @@ class ArtistDetailFragment : DetailFragment() {
setOnMenuItemClickListener { setOnMenuItemClickListener {
when (it.itemId) { when (it.itemId) {
R.id.action_shuffle -> playbackModel.playArtist( R.id.action_shuffle -> {
detailModel.currentArtist.value!!, playbackModel.playArtist(
true detailModel.currentArtist.value!!,
) true
R.id.action_play -> playbackModel.playArtist( )
detailModel.currentArtist.value!!, false
)
}
true true
}
R.id.action_play -> {
playbackModel.playArtist(
detailModel.currentArtist.value!!, false
)
true
}
else -> false
}
} }
} }

View file

@ -75,16 +75,24 @@ class GenreDetailFragment : DetailFragment() {
setOnMenuItemClickListener { setOnMenuItemClickListener {
when (it.itemId) { when (it.itemId) {
R.id.action_shuffle -> playbackModel.playGenre( R.id.action_shuffle -> {
detailModel.currentGenre.value!!, playbackModel.playGenre(
true detailModel.currentGenre.value!!,
) true
R.id.action_play -> playbackModel.playGenre( )
detailModel.currentGenre.value!!, false
)
}
true true
}
R.id.action_play -> {
playbackModel.playGenre(
detailModel.currentGenre.value!!, false
)
true
}
else -> false
}
} }
} }

View file

@ -80,6 +80,7 @@ class LibraryFragment : Fragment(), SearchView.OnQueryTextListener {
) )
it.expandActionView() it.expandActionView()
} }
true true
} }

View file

@ -75,9 +75,9 @@ class PlaybackFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
setOnMenuItemClickListener { setOnMenuItemClickListener {
if (it.itemId == R.id.action_queue) { if (it.itemId == R.id.action_queue) {
findNavController().navigate(PlaybackFragmentDirections.actionShowQueue()) findNavController().navigate(PlaybackFragmentDirections.actionShowQueue())
}
true true
} else false
} }
queueMenuItem = menu.findItem(R.id.action_queue) queueMenuItem = menu.findItem(R.id.action_queue)

View file

@ -107,7 +107,6 @@ class SettingsListFragment : PreferenceFragmentCompat() {
) )
} }
// TODO: Implement dialog edge-to-edge
layoutManager = LinearLayoutManager( layoutManager = LinearLayoutManager(
requireContext() requireContext()
).also { it.orientation = LinearLayoutManager.HORIZONTAL } ).also { it.orientation = LinearLayoutManager.HORIZONTAL }

View file

@ -6,7 +6,6 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.PopupMenu
import androidx.appcompat.widget.SearchView
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -24,7 +23,7 @@ import org.oxycblt.auxio.ui.setupSongActions
* them. * them.
* @author OxygenCobalt * @author OxygenCobalt
*/ */
class SongsFragment : Fragment(), SearchView.OnQueryTextListener { class SongsFragment : Fragment() {
private val playbackModel: PlaybackViewModel by activityViewModels() private val playbackModel: PlaybackViewModel by activityViewModels()
override fun onCreateView( override fun onCreateView(
@ -52,8 +51,9 @@ class SongsFragment : Fragment(), SearchView.OnQueryTextListener {
setOnMenuItemClickListener { setOnMenuItemClickListener {
if (it.itemId == R.id.action_shuffle) { if (it.itemId == R.id.action_shuffle) {
playbackModel.shuffleAll() playbackModel.shuffleAll()
}
true true
} else false
} }
} }
@ -69,28 +69,16 @@ class SongsFragment : Fragment(), SearchView.OnQueryTextListener {
return binding.root return binding.root
} }
override fun onQueryTextChange(newText: String?): Boolean {
return false
}
override fun onQueryTextSubmit(query: String?): Boolean {
return false
}
private fun setupFastScroller(binding: FragmentSongsBinding) { private fun setupFastScroller(binding: FragmentSongsBinding) {
val musicStore = MusicStore.getInstance() val musicStore = MusicStore.getInstance()
binding.songFastScroll.apply { binding.songFastScroll.apply {
var hasAddedNumber = false var hasAddedNumber = false
var iters = 0
// TODO: Do selection instead of using iters
setupWithRecyclerView( setupWithRecyclerView(
binding.songRecycler, binding.songRecycler,
{ pos -> { pos ->
val item = musicStore.songs[pos] val item = musicStore.songs[pos]
iters++
// If the item starts with "the"/"a", then actually use the character after that // 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] // 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() item.name[0].toUpperCase()
} }
// Check if this song starts with a number, if so, then concat it with a single // Use "#" if the character is a digit.
// "Numeric" item if haven't already. if (char.isDigit()) {
// This check only occurs on the second time the fast scroller is polled for items. FastScrollItemIndicator.Text("#")
if (iters >= musicStore.songs.size) { } else {
if (char.isDigit()) { FastScrollItemIndicator.Text(char.toString())
if (!hasAddedNumber) {
hasAddedNumber = true
return@setupWithRecyclerView FastScrollItemIndicator.Text("#")
} else {
return@setupWithRecyclerView null
}
}
} }
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 useDefaultScroller = false
itemIndicatorSelectedCallbacks.add(object : itemIndicatorSelectedCallbacks.add(
FastScrollerView.ItemIndicatorSelectedCallback { object : FastScrollerView.ItemIndicatorSelectedCallback {
override fun onItemIndicatorSelected( override fun onItemIndicatorSelected(
indicator: FastScrollItemIndicator, indicator: FastScrollItemIndicator,
indicatorCenterY: Int, indicatorCenterY: Int,

View file

@ -27,6 +27,7 @@
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/album_toolbar" android:id="@+id/album_toolbar"
style="@style/Toolbar.Style.Icon" style="@style/Toolbar.Style.Icon"
android:elevation="@dimen/elevation_normal"
app:menu="@menu/menu_album_actions" app:menu="@menu/menu_album_actions"
app:title="@string/label_library" /> app:title="@string/label_library" />

View file

@ -27,6 +27,7 @@
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/artist_toolbar" android:id="@+id/artist_toolbar"
style="@style/Toolbar.Style.Icon" style="@style/Toolbar.Style.Icon"
android:elevation="@dimen/elevation_normal"
app:menu="@menu/menu_detail" app:menu="@menu/menu_detail"
app:title="@string/label_library" /> app:title="@string/label_library" />

View file

@ -27,6 +27,7 @@
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/genre_toolbar" android:id="@+id/genre_toolbar"
style="@style/Toolbar.Style.Icon" style="@style/Toolbar.Style.Icon"
android:elevation="@dimen/elevation_normal"
app:menu="@menu/menu_detail" app:menu="@menu/menu_detail"
app:title="@string/label_library" /> app:title="@string/label_library" />

View file

@ -14,6 +14,7 @@
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/queue_toolbar" android:id="@+id/queue_toolbar"
style="@style/Toolbar.Style.Icon" style="@style/Toolbar.Style.Icon"
android:elevation="@dimen/elevation_normal"
app:navigationIcon="@drawable/ic_down" app:navigationIcon="@drawable/ic_down"
app:title="@string/label_queue" /> app:title="@string/label_queue" />

View file

@ -10,6 +10,7 @@
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/song_toolbar" android:id="@+id/song_toolbar"
style="@style/Toolbar.Style" style="@style/Toolbar.Style"
android:elevation="@dimen/elevation_normal"
app:title="@string/setting_title" /> app:title="@string/setting_title" />
<androidx.fragment.app.FragmentContainerView <androidx.fragment.app.FragmentContainerView

View file

@ -13,6 +13,7 @@
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/song_toolbar" android:id="@+id/song_toolbar"
style="@style/Toolbar.Style" style="@style/Toolbar.Style"
android:elevation="@dimen/elevation_normal"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:menu="@menu/menu_songs" app:menu="@menu/menu_songs"
@ -39,7 +40,7 @@
<org.oxycblt.auxio.recycler.NoLeakThumbView <org.oxycblt.auxio.recycler.NoLeakThumbView
android:id="@+id/song_fast_scroll_thumb" android:id="@+id/song_fast_scroll_thumb"
android:layout_width="50dp" android:layout_width="@dimen/width_thumb_view"
android:layout_height="0dp" android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/song_fast_scroll" app:layout_constraintEnd_toStartOf="@+id/song_fast_scroll"

View file

@ -16,6 +16,7 @@
<!-- Width Namespace | Width for UI elements --> <!-- Width Namespace | Width for UI elements -->
<dimen name="width_track_number">32dp</dimen> <dimen name="width_track_number">32dp</dimen>
<dimen name="width_thumb_view">50dp</dimen>
<!-- Size Namespace | Width & Heights for UI elements --> <!-- Size Namespace | Width & Heights for UI elements -->
<dimen name="size_error_icon">48dp</dimen> <dimen name="size_error_icon">48dp</dimen>

View file

@ -26,21 +26,27 @@
<style name="Toolbar.Style" parent="ThemeOverlay.MaterialComponents.ActionBar"> <style name="Toolbar.Style" parent="ThemeOverlay.MaterialComponents.ActionBar">
<item name="android:layout_width">match_parent</item> <item name="android:layout_width">match_parent</item>
<item name="android:layout_height">?android:attr/actionBarSize</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> <item name="titleTextAppearance">@style/TextAppearance.Toolbar.Header</item>
</style> </style>
<!-- Toolbar sub-style with a nav icon -->
<style name="Toolbar.Style.Icon" parent="Toolbar.Style"> <style name="Toolbar.Style.Icon" parent="Toolbar.Style">
<item name="navigationIcon">@drawable/ic_back</item> <item name="navigationIcon">@drawable/ic_back</item>
</style> </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"> <style name="Toolbar.Style.Search" parent="Toolbar.Style">
<item name="android:searchViewStyle">@style/Widget.AppCompat.SearchView</item> <item name="android:searchViewStyle">@style/Widget.AppCompat.SearchView</item>
</style> </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 --> <!-- Toolbar Title Theme -->
<style name="TextAppearance.Toolbar.Header" parent="TextAppearance.Widget.AppCompat.Toolbar.Title"> <style name="TextAppearance.Toolbar.Header" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="android:fontFamily">@font/inter_black</item> <item name="android:fontFamily">@font/inter_black</item>
@ -62,7 +68,6 @@
<!-- Custom popup menu theme --> <!-- Custom popup menu theme -->
<style name="Widget.CustomPopup" parent="Widget.AppCompat.PopupMenu"> <style name="Widget.CustomPopup" parent="Widget.AppCompat.PopupMenu">
<item name="android:colorBackground">@color/background</item>
<item name="android:popupBackground">@color/background</item> <item name="android:popupBackground">@color/background</item>
<item name="colorControlHighlight">@color/selection_color</item> <item name="colorControlHighlight">@color/selection_color</item>
<item name="cornerRadius">0dp</item> <item name="cornerRadius">0dp</item>
@ -143,6 +148,7 @@
<item name="android:background">@drawable/ui_header_dividers</item> <item name="android:background">@drawable/ui_header_dividers</item>
</style> </style>
<!-- Style for an action header -->
<style name="HeaderAction"> <style name="HeaderAction">
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">0dp</item> <item name="android:layout_width">0dp</item>