Add back navigation to detail fragments
Add backwards navigation to the DetailFragment toolbars.
This commit is contained in:
@@ -55,6 +55,10 @@ class AlbumDetailFragment : Fragment() {
|
||||
binding.songRecycler.applyDivider()
|
||||
binding.songRecycler.setHasFixedSize(true)
|
||||
|
||||
binding.toolbar.setNavigationOnClickListener {
|
||||
findNavController().navigateUp()
|
||||
}
|
||||
|
||||
// If the album was shown directly from LibraryFragment [No parent artist stored],
|
||||
// then enable the ability to navigate upwards to the album's parent artist.
|
||||
if (detailModel.currentArtist == null) {
|
||||
@@ -75,7 +79,6 @@ class AlbumDetailFragment : Fragment() {
|
||||
binding.artistName.setBackgroundResource(R.drawable.ripple)
|
||||
}
|
||||
|
||||
// Set up sort modes
|
||||
detailModel.albumSortMode.observe(viewLifecycleOwner) { mode ->
|
||||
// Update the current sort icon
|
||||
binding.sortButton.setImageResource(mode.iconRes)
|
||||
@@ -93,7 +96,7 @@ class AlbumDetailFragment : Fragment() {
|
||||
)
|
||||
}
|
||||
|
||||
// Dont enable the sort button if theres only one song [or less]
|
||||
// Don't enable the sort button if there's only one song [or less]
|
||||
if (detailModel.currentAlbum!!.numSongs < 2) {
|
||||
binding.sortButton.imageTintList = ColorStateList.valueOf(
|
||||
R.color.inactive_color.toColor(requireContext())
|
||||
|
||||
@@ -55,6 +55,10 @@ class ArtistDetailFragment : Fragment() {
|
||||
binding.albumRecycler.applyDivider()
|
||||
binding.albumRecycler.setHasFixedSize(true)
|
||||
|
||||
binding.toolbar.setNavigationOnClickListener {
|
||||
findNavController().navigateUp()
|
||||
}
|
||||
|
||||
detailModel.artistSortMode.observe(viewLifecycleOwner) { mode ->
|
||||
// Update the current sort icon
|
||||
binding.sortButton.setImageResource(mode.iconRes)
|
||||
@@ -72,7 +76,7 @@ class ArtistDetailFragment : Fragment() {
|
||||
)
|
||||
}
|
||||
|
||||
// Dont enable the sort button if there is only one album [Or less]
|
||||
// Don't enable the sort button if there is only one album [Or less]
|
||||
if (detailModel.currentArtist!!.numAlbums < 2) {
|
||||
binding.sortButton.imageTintList = ColorStateList.valueOf(
|
||||
R.color.inactive_color.toColor(requireContext())
|
||||
|
||||
@@ -21,8 +21,6 @@ import org.oxycblt.auxio.music.processing.MusicLoaderResponse
|
||||
import org.oxycblt.auxio.music.processing.MusicSorter
|
||||
|
||||
// ViewModel for music storage. May also be a god object.
|
||||
// TODO: Move the lists from the music models to a map, would
|
||||
// make some systems a lot less hacky and maybe decrease memory usage.
|
||||
class MusicViewModel(private val app: Application) : ViewModel() {
|
||||
|
||||
// Coroutine
|
||||
|
||||
@@ -118,7 +118,7 @@ class MusicLoader(
|
||||
Genres.Members.getContentUri("external", genre.id),
|
||||
arrayOf(
|
||||
Artists._ID, // 0
|
||||
Artists.ARTIST, // 1
|
||||
Artists.ARTIST // 1
|
||||
),
|
||||
null, null,
|
||||
Artists.DEFAULT_SORT_ORDER
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.oxycblt.auxio.theme
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
@@ -34,6 +35,7 @@ private val ACCENTS = listOf(
|
||||
val accent = ACCENTS[5]
|
||||
|
||||
// Get the transparent variant of a color int
|
||||
@ColorInt
|
||||
fun getTransparentAccent(context: Context, color: Int, alpha: Int): Int {
|
||||
return ColorUtils.setAlphaComponent(
|
||||
ContextCompat.getColor(context, color),
|
||||
@@ -42,11 +44,13 @@ fun getTransparentAccent(context: Context, color: Int, alpha: Int): Int {
|
||||
}
|
||||
|
||||
// Get the inactive transparency of an accent
|
||||
@ColorInt
|
||||
fun getInactiveAlpha(color: Int): Int {
|
||||
return if (color == R.color.yellow) 100 else 150
|
||||
}
|
||||
|
||||
// Convert an integer to a color
|
||||
@ColorInt
|
||||
fun Int.toColor(context: Context): Int {
|
||||
return try {
|
||||
ContextCompat.getColor(context, this)
|
||||
|
||||
Reference in New Issue
Block a user