Redesign toolbar

Remove the "Library" name from the toolbar and make it more of a bar for certain actions.
This commit is contained in:
OxygenCobalt
2021-01-03 19:01:06 -07:00
parent ee1d05d347
commit 4c1f009d93
6 changed files with 52 additions and 69 deletions
@@ -85,6 +85,16 @@ abstract class DetailFragment : Fragment() {
}
}
}
addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
overScrollMode = if (computeVerticalScrollOffset() == 0) {
View.OVER_SCROLL_NEVER
} else {
View.OVER_SCROLL_IF_CONTENT_SCROLLS
}
}
})
}
}
@@ -1,13 +1,11 @@
package org.oxycblt.auxio.detail.adapters
import android.content.res.ColorStateList
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import org.oxycblt.auxio.R
import org.oxycblt.auxio.databinding.ItemAlbumHeaderBinding
import org.oxycblt.auxio.databinding.ItemAlbumSongBinding
import org.oxycblt.auxio.detail.DetailViewModel
@@ -19,9 +17,9 @@ import org.oxycblt.auxio.recycler.DiffCallback
import org.oxycblt.auxio.recycler.viewholders.BaseViewHolder
import org.oxycblt.auxio.recycler.viewholders.Highlightable
import org.oxycblt.auxio.ui.accent
import org.oxycblt.auxio.ui.applyAccents
import org.oxycblt.auxio.ui.disable
import org.oxycblt.auxio.ui.setTextColorResource
import org.oxycblt.auxio.ui.toColor
/**
* An adapter for displaying the details and [Song]s of an [Album]
@@ -117,21 +115,8 @@ class AlbumDetailAdapter(
binding.playbackModel = playbackModel
binding.lifecycleOwner = lifecycleOwner
// Apply the accent programmatically since I don't want to deal the with the
// nightmarish mess of switching out my styling to Material
val accent = accent.first.toColor(binding.albumShuffleButton.context)
val selection = ColorStateList.valueOf(
R.color.selection_color.toColor(binding.albumShuffleButton.context)
)
binding.albumShuffleButton.apply {
backgroundTintList = ColorStateList.valueOf(accent)
rippleColor = selection
}
binding.albumPlayButton.apply {
setTextColor(accent)
rippleColor = selection
}
binding.albumShuffleButton.applyAccents(true)
binding.albumPlayButton.applyAccents(false)
if (data.songs.size < 2) {
binding.albumSortButton.disable()
@@ -1,13 +1,11 @@
package org.oxycblt.auxio.detail.adapters
import android.content.res.ColorStateList
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import org.oxycblt.auxio.R
import org.oxycblt.auxio.databinding.ItemArtistAlbumBinding
import org.oxycblt.auxio.databinding.ItemArtistHeaderBinding
import org.oxycblt.auxio.detail.DetailViewModel
@@ -19,9 +17,9 @@ import org.oxycblt.auxio.recycler.DiffCallback
import org.oxycblt.auxio.recycler.viewholders.BaseViewHolder
import org.oxycblt.auxio.recycler.viewholders.Highlightable
import org.oxycblt.auxio.ui.accent
import org.oxycblt.auxio.ui.applyAccents
import org.oxycblt.auxio.ui.disable
import org.oxycblt.auxio.ui.setTextColorResource
import org.oxycblt.auxio.ui.toColor
/**
* An adapter for displaying the [Album]s of an artist.
@@ -116,22 +114,8 @@ class ArtistDetailAdapter(
binding.playbackModel = playbackModel
binding.lifecycleOwner = lifecycleOwner
// Apply the accent programmatically since I don't want to deal the with the
// nightmarish mess of switching out my styling to Material
val accent = accent.first.toColor(binding.artistShuffleButton.context)
val selection = ColorStateList.valueOf(
R.color.selection_color.toColor(binding.artistShuffleButton.context)
)
binding.artistShuffleButton.apply {
backgroundTintList = ColorStateList.valueOf(accent)
rippleColor = selection
}
binding.artistPlayButton.apply {
setTextColor(accent)
rippleColor = selection
}
binding.artistShuffleButton.applyAccents(true)
binding.artistPlayButton.applyAccents(false)
if (data.albums.size < 2) {
binding.artistSortButton.disable()
@@ -1,13 +1,11 @@
package org.oxycblt.auxio.detail.adapters
import android.content.res.ColorStateList
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import org.oxycblt.auxio.R
import org.oxycblt.auxio.databinding.ItemGenreHeaderBinding
import org.oxycblt.auxio.databinding.ItemGenreSongBinding
import org.oxycblt.auxio.detail.DetailViewModel
@@ -19,9 +17,9 @@ import org.oxycblt.auxio.recycler.DiffCallback
import org.oxycblt.auxio.recycler.viewholders.BaseViewHolder
import org.oxycblt.auxio.recycler.viewholders.Highlightable
import org.oxycblt.auxio.ui.accent
import org.oxycblt.auxio.ui.applyAccents
import org.oxycblt.auxio.ui.disable
import org.oxycblt.auxio.ui.setTextColorResource
import org.oxycblt.auxio.ui.toColor
/**
* An adapter for displaying the [Song]s of a genre.
@@ -117,22 +115,8 @@ class GenreDetailAdapter(
binding.playbackModel = playbackModel
binding.lifecycleOwner = lifecycleOwner
// Apply the accent programmatically since I don't want to deal the with the
// nightmarish mess of switching out my styling to Material
val accent = accent.first.toColor(binding.genreShuffleButton.context)
val selection = ColorStateList.valueOf(
R.color.selection_color.toColor(binding.genreShuffleButton.context)
)
binding.genreShuffleButton.apply {
backgroundTintList = ColorStateList.valueOf(accent)
rippleColor = selection
}
binding.genrePlayButton.apply {
setTextColor(accent)
rippleColor = selection
}
binding.genreShuffleButton.applyAccents(true)
binding.genrePlayButton.applyAccents(false)
if (data.songs.size < 2) {
binding.genreSortButton.disable()
@@ -16,6 +16,7 @@ import androidx.annotation.ColorRes
import androidx.annotation.MenuRes
import androidx.appcompat.widget.PopupMenu
import androidx.core.text.HtmlCompat
import com.google.android.material.button.MaterialButton
import org.oxycblt.auxio.R
import org.oxycblt.auxio.detail.DetailViewModel
import org.oxycblt.auxio.music.Album
@@ -90,6 +91,21 @@ fun TextView.setTextColorResource(@ColorRes color: Int) {
setTextColor(color.toColor(context))
}
/**
* Apply accents to a [MaterialButton]
* @param highlighted Whether the MaterialButton has an "Unimportant" style or not.
* Required because you cant determine a style of a view before 29
*/
fun MaterialButton.applyAccents(highlighted: Boolean) {
val accent = accent.first.toColor(context)
if (highlighted) {
backgroundTintList = ColorStateList.valueOf(accent)
} else {
setTextColor(accent)
}
}
/**
* Show actions for a song item, such as the ones found in [org.oxycblt.auxio.songs.SongsFragment]
* @param context [Context] required