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
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
6 changed files with 52 additions and 69 deletions

View file

@ -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
}
}
})
} }
} }

View file

@ -1,13 +1,11 @@
package org.oxycblt.auxio.detail.adapters package org.oxycblt.auxio.detail.adapters
import android.content.res.ColorStateList
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import org.oxycblt.auxio.R
import org.oxycblt.auxio.databinding.ItemAlbumHeaderBinding import org.oxycblt.auxio.databinding.ItemAlbumHeaderBinding
import org.oxycblt.auxio.databinding.ItemAlbumSongBinding import org.oxycblt.auxio.databinding.ItemAlbumSongBinding
import org.oxycblt.auxio.detail.DetailViewModel 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.BaseViewHolder
import org.oxycblt.auxio.recycler.viewholders.Highlightable import org.oxycblt.auxio.recycler.viewholders.Highlightable
import org.oxycblt.auxio.ui.accent import org.oxycblt.auxio.ui.accent
import org.oxycblt.auxio.ui.applyAccents
import org.oxycblt.auxio.ui.disable import org.oxycblt.auxio.ui.disable
import org.oxycblt.auxio.ui.setTextColorResource import org.oxycblt.auxio.ui.setTextColorResource
import org.oxycblt.auxio.ui.toColor
/** /**
* An adapter for displaying the details and [Song]s of an [Album] * An adapter for displaying the details and [Song]s of an [Album]
@ -117,21 +115,8 @@ class AlbumDetailAdapter(
binding.playbackModel = playbackModel binding.playbackModel = playbackModel
binding.lifecycleOwner = lifecycleOwner binding.lifecycleOwner = lifecycleOwner
// Apply the accent programmatically since I don't want to deal the with the binding.albumShuffleButton.applyAccents(true)
// nightmarish mess of switching out my styling to Material binding.albumPlayButton.applyAccents(false)
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
}
if (data.songs.size < 2) { if (data.songs.size < 2) {
binding.albumSortButton.disable() binding.albumSortButton.disable()

View file

@ -1,13 +1,11 @@
package org.oxycblt.auxio.detail.adapters package org.oxycblt.auxio.detail.adapters
import android.content.res.ColorStateList
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import org.oxycblt.auxio.R
import org.oxycblt.auxio.databinding.ItemArtistAlbumBinding import org.oxycblt.auxio.databinding.ItemArtistAlbumBinding
import org.oxycblt.auxio.databinding.ItemArtistHeaderBinding import org.oxycblt.auxio.databinding.ItemArtistHeaderBinding
import org.oxycblt.auxio.detail.DetailViewModel 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.BaseViewHolder
import org.oxycblt.auxio.recycler.viewholders.Highlightable import org.oxycblt.auxio.recycler.viewholders.Highlightable
import org.oxycblt.auxio.ui.accent import org.oxycblt.auxio.ui.accent
import org.oxycblt.auxio.ui.applyAccents
import org.oxycblt.auxio.ui.disable import org.oxycblt.auxio.ui.disable
import org.oxycblt.auxio.ui.setTextColorResource import org.oxycblt.auxio.ui.setTextColorResource
import org.oxycblt.auxio.ui.toColor
/** /**
* An adapter for displaying the [Album]s of an artist. * An adapter for displaying the [Album]s of an artist.
@ -116,22 +114,8 @@ class ArtistDetailAdapter(
binding.playbackModel = playbackModel binding.playbackModel = playbackModel
binding.lifecycleOwner = lifecycleOwner binding.lifecycleOwner = lifecycleOwner
// Apply the accent programmatically since I don't want to deal the with the binding.artistShuffleButton.applyAccents(true)
// nightmarish mess of switching out my styling to Material binding.artistPlayButton.applyAccents(false)
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
}
if (data.albums.size < 2) { if (data.albums.size < 2) {
binding.artistSortButton.disable() binding.artistSortButton.disable()

View file

@ -1,13 +1,11 @@
package org.oxycblt.auxio.detail.adapters package org.oxycblt.auxio.detail.adapters
import android.content.res.ColorStateList
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import org.oxycblt.auxio.R
import org.oxycblt.auxio.databinding.ItemGenreHeaderBinding import org.oxycblt.auxio.databinding.ItemGenreHeaderBinding
import org.oxycblt.auxio.databinding.ItemGenreSongBinding import org.oxycblt.auxio.databinding.ItemGenreSongBinding
import org.oxycblt.auxio.detail.DetailViewModel 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.BaseViewHolder
import org.oxycblt.auxio.recycler.viewholders.Highlightable import org.oxycblt.auxio.recycler.viewholders.Highlightable
import org.oxycblt.auxio.ui.accent import org.oxycblt.auxio.ui.accent
import org.oxycblt.auxio.ui.applyAccents
import org.oxycblt.auxio.ui.disable import org.oxycblt.auxio.ui.disable
import org.oxycblt.auxio.ui.setTextColorResource import org.oxycblt.auxio.ui.setTextColorResource
import org.oxycblt.auxio.ui.toColor
/** /**
* An adapter for displaying the [Song]s of a genre. * An adapter for displaying the [Song]s of a genre.
@ -117,22 +115,8 @@ class GenreDetailAdapter(
binding.playbackModel = playbackModel binding.playbackModel = playbackModel
binding.lifecycleOwner = lifecycleOwner binding.lifecycleOwner = lifecycleOwner
// Apply the accent programmatically since I don't want to deal the with the binding.genreShuffleButton.applyAccents(true)
// nightmarish mess of switching out my styling to Material binding.genrePlayButton.applyAccents(false)
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
}
if (data.songs.size < 2) { if (data.songs.size < 2) {
binding.genreSortButton.disable() binding.genreSortButton.disable()

View file

@ -16,6 +16,7 @@ import androidx.annotation.ColorRes
import androidx.annotation.MenuRes import androidx.annotation.MenuRes
import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.PopupMenu
import androidx.core.text.HtmlCompat import androidx.core.text.HtmlCompat
import com.google.android.material.button.MaterialButton
import org.oxycblt.auxio.R import org.oxycblt.auxio.R
import org.oxycblt.auxio.detail.DetailViewModel import org.oxycblt.auxio.detail.DetailViewModel
import org.oxycblt.auxio.music.Album import org.oxycblt.auxio.music.Album
@ -90,6 +91,21 @@ fun TextView.setTextColorResource(@ColorRes color: Int) {
setTextColor(color.toColor(context)) 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] * Show actions for a song item, such as the ones found in [org.oxycblt.auxio.songs.SongsFragment]
* @param context [Context] required * @param context [Context] required

View file

@ -4,28 +4,32 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
tools:context=".detail.GenreDetailFragment"> tools:context=".detail.GenreDetailFragment">
<LinearLayout <androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:liftOnScroll="true">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/detail_toolbar" android:id="@+id/detail_toolbar"
style="@style/Toolbar.Style.Icon" style="@style/Toolbar.Style.Icon"
android:background="?android:attr/windowBackground" android:background="?android:attr/windowBackground"
android:elevation="@dimen/elevation_normal" android:elevation="@dimen/elevation_normal" />
app:title="@string/label_library"
tools:menu="@menu/menu_artist_actions" /> </com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/detail_recycler" android:id="@+id/detail_recycler"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="match_parent"
android:layout_weight="1" android:layout_marginTop="?attr/actionBarSize"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/genre_song_header" app:layout_constraintTop_toBottomOf="@+id/genre_song_header"
tools:listitem="@layout/item_artist_header" /> tools:listitem="@layout/item_artist_header" />
</LinearLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout> </layout>