ui: fix material issues
Migrate dividers over to material theming alongside making detail items use a colorStateList instead of manually indexing for text colors.
This commit is contained in:
parent
23e3c0241d
commit
34367b3bae
28 changed files with 41 additions and 62 deletions
|
@ -23,7 +23,6 @@ import android.view.ViewGroup
|
|||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.oxycblt.auxio.accent.Accent
|
||||
import org.oxycblt.auxio.databinding.ItemAlbumHeaderBinding
|
||||
import org.oxycblt.auxio.databinding.ItemAlbumSongBinding
|
||||
import org.oxycblt.auxio.detail.DetailViewModel
|
||||
|
@ -35,7 +34,6 @@ import org.oxycblt.auxio.ui.BaseViewHolder
|
|||
import org.oxycblt.auxio.ui.DiffCallback
|
||||
import org.oxycblt.auxio.util.disable
|
||||
import org.oxycblt.auxio.util.inflater
|
||||
import org.oxycblt.auxio.util.setTextColorResource
|
||||
|
||||
/**
|
||||
* An adapter for displaying the details and [Song]s of an [Album]
|
||||
|
@ -48,7 +46,6 @@ class AlbumDetailAdapter(
|
|||
private val doOnClick: (data: Song) -> Unit,
|
||||
private val doOnLongClick: (view: View, data: Song) -> Unit
|
||||
) : ListAdapter<BaseModel, RecyclerView.ViewHolder>(DiffCallback()) {
|
||||
|
||||
private var currentSong: Song? = null
|
||||
private var lastHolder: Highlightable? = null
|
||||
|
||||
|
@ -145,9 +142,6 @@ class AlbumDetailAdapter(
|
|||
inner class AlbumSongViewHolder(
|
||||
private val binding: ItemAlbumSongBinding,
|
||||
) : BaseViewHolder<Song>(binding, doOnClick, doOnLongClick), Highlightable {
|
||||
private val normalTextColor = binding.songName.currentTextColor
|
||||
private val inactiveTextColor = binding.songTrack.currentTextColor
|
||||
|
||||
override fun onBind(data: Song) {
|
||||
binding.song = data
|
||||
|
||||
|
@ -155,15 +149,8 @@ class AlbumDetailAdapter(
|
|||
}
|
||||
|
||||
override fun setHighlighted(isHighlighted: Boolean) {
|
||||
if (isHighlighted) {
|
||||
val accent = Accent.get()
|
||||
|
||||
binding.songName.setTextColorResource(accent.color)
|
||||
binding.songTrack.setTextColorResource(accent.color)
|
||||
} else {
|
||||
binding.songName.setTextColor(normalTextColor)
|
||||
binding.songTrack.setTextColor(inactiveTextColor)
|
||||
}
|
||||
binding.songName.isActivated = isHighlighted
|
||||
binding.songTrack.isActivated = isHighlighted
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.oxycblt.auxio.accent.Accent
|
||||
import org.oxycblt.auxio.databinding.ItemActionHeaderBinding
|
||||
import org.oxycblt.auxio.databinding.ItemArtistAlbumBinding
|
||||
import org.oxycblt.auxio.databinding.ItemArtistHeaderBinding
|
||||
|
@ -38,8 +37,6 @@ import org.oxycblt.auxio.ui.BaseViewHolder
|
|||
import org.oxycblt.auxio.ui.DiffCallback
|
||||
import org.oxycblt.auxio.util.disable
|
||||
import org.oxycblt.auxio.util.inflater
|
||||
import org.oxycblt.auxio.util.logD
|
||||
import org.oxycblt.auxio.util.setTextColorResource
|
||||
|
||||
/**
|
||||
* An adapter for displaying the [Album]s and [Song]s of an artist.
|
||||
|
@ -195,8 +192,6 @@ class ArtistDetailAdapter(
|
|||
inner class ArtistAlbumViewHolder(
|
||||
private val binding: ItemArtistAlbumBinding,
|
||||
) : BaseViewHolder<Album>(binding, doOnClick, doOnLongClick), Highlightable {
|
||||
private val normalTextColor = binding.albumName.currentTextColor
|
||||
|
||||
override fun onBind(data: Album) {
|
||||
binding.album = data
|
||||
|
||||
|
@ -204,13 +199,7 @@ class ArtistDetailAdapter(
|
|||
}
|
||||
|
||||
override fun setHighlighted(isHighlighted: Boolean) {
|
||||
logD(isHighlighted)
|
||||
|
||||
if (isHighlighted) {
|
||||
binding.albumName.setTextColorResource(Accent.get().color)
|
||||
} else {
|
||||
binding.albumName.setTextColor(normalTextColor)
|
||||
}
|
||||
binding.albumName.isActivated = isHighlighted
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,11 +240,7 @@ class ArtistDetailAdapter(
|
|||
}
|
||||
|
||||
override fun setHighlighted(isHighlighted: Boolean) {
|
||||
if (isHighlighted) {
|
||||
binding.songName.setTextColorResource(Accent.get().color)
|
||||
} else {
|
||||
binding.songName.setTextColor(normalTextColor)
|
||||
}
|
||||
binding.songName.isActivated = isHighlighted
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import android.view.ViewGroup
|
|||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.oxycblt.auxio.accent.Accent
|
||||
import org.oxycblt.auxio.databinding.ItemGenreHeaderBinding
|
||||
import org.oxycblt.auxio.databinding.ItemGenreSongBinding
|
||||
import org.oxycblt.auxio.detail.DetailViewModel
|
||||
|
@ -35,7 +34,6 @@ import org.oxycblt.auxio.ui.BaseViewHolder
|
|||
import org.oxycblt.auxio.ui.DiffCallback
|
||||
import org.oxycblt.auxio.util.disable
|
||||
import org.oxycblt.auxio.util.inflater
|
||||
import org.oxycblt.auxio.util.setTextColorResource
|
||||
|
||||
/**
|
||||
* An adapter for displaying the [Song]s of a genre.
|
||||
|
@ -48,7 +46,6 @@ class GenreDetailAdapter(
|
|||
private val doOnClick: (data: Song) -> Unit,
|
||||
private val doOnLongClick: (view: View, data: Song) -> Unit
|
||||
) : ListAdapter<BaseModel, RecyclerView.ViewHolder>(DiffCallback()) {
|
||||
|
||||
private var currentSong: Song? = null
|
||||
private var lastHolder: Highlightable? = null
|
||||
|
||||
|
@ -145,8 +142,6 @@ class GenreDetailAdapter(
|
|||
inner class GenreSongViewHolder(
|
||||
private val binding: ItemGenreSongBinding,
|
||||
) : BaseViewHolder<Song>(binding, doOnClick, doOnLongClick), Highlightable {
|
||||
private val normalTextColor = binding.songName.currentTextColor
|
||||
|
||||
override fun onBind(data: Song) {
|
||||
binding.song = data
|
||||
|
||||
|
@ -155,11 +150,7 @@ class GenreDetailAdapter(
|
|||
}
|
||||
|
||||
override fun setHighlighted(isHighlighted: Boolean) {
|
||||
if (isHighlighted) {
|
||||
binding.songName.setTextColorResource(Accent.get().color)
|
||||
} else {
|
||||
binding.songName.setTextColor(normalTextColor)
|
||||
}
|
||||
binding.songName.isActivated = isHighlighted
|
||||
}
|
||||
}
|
||||
|
||||
|
|
4
app/src/main/res/color/overlay_divider.xml
Normal file
4
app/src/main/res/color/overlay_divider.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?attr/colorOnSurface" android:alpha="0.12" />
|
||||
</selector>
|
6
app/src/main/res/color/sel_accented_primary.xml
Normal file
6
app/src/main/res/color/sel_accented_primary.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?attr/colorAccent"
|
||||
android:state_activated="true" />
|
||||
<item android:color="?android:attr/textColorPrimary" />
|
||||
</selector>
|
6
app/src/main/res/color/sel_accented_track.xml
Normal file
6
app/src/main/res/color/sel_accented_track.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?attr/colorAccent"
|
||||
android:state_activated="true" />
|
||||
<item android:color="?android:attr/textColorTertiary" />
|
||||
</selector>
|
|
@ -3,7 +3,7 @@
|
|||
android:color="?attr/colorControlHighlight">
|
||||
<item>
|
||||
<shape android:shape="oval"
|
||||
android:tint="@color/color_accent_active">
|
||||
android:tint="@color/sel_accent_active">
|
||||
<solid android:color="@android:color/white" />
|
||||
</shape>
|
||||
</item>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<shape android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="@dimen/size_stroke_small"
|
||||
android:color="@color/divider" />
|
||||
android:color="@color/overlay_divider" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="@color/color_popup_overlay" />
|
||||
<solid android:color="@color/overlay_popup" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -183,7 +183,7 @@
|
|||
android:contentDescription="@string/desc_shuffle"
|
||||
android:onClick="@{() -> playbackModel.invertShuffleStatus()}"
|
||||
android:src="@drawable/ic_shuffle"
|
||||
app:tint="@color/color_accent_active"
|
||||
app:tint="@color/sel_accent_active"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/playback_skip_next"
|
||||
app:layout_constraintEnd_toEndOf="@+id/playback_song_duration"
|
||||
app:layout_constraintTop_toTopOf="@+id/playback_skip_next" />
|
||||
|
|
|
@ -184,7 +184,7 @@
|
|||
android:contentDescription="@string/desc_shuffle"
|
||||
android:onClick="@{() -> playbackModel.invertShuffleStatus()}"
|
||||
android:src="@drawable/ic_shuffle"
|
||||
app:tint="@color/color_accent_active"
|
||||
app:tint="@color/sel_accent_active"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/playback_skip_next"
|
||||
app:layout_constraintStart_toEndOf="@+id/playback_skip_next"
|
||||
app:layout_constraintTop_toTopOf="@+id/playback_skip_next" />
|
||||
|
|
|
@ -171,7 +171,7 @@
|
|||
android:contentDescription="@string/desc_shuffle"
|
||||
android:onClick="@{() -> playbackModel.invertShuffleStatus()}"
|
||||
android:src="@drawable/ic_shuffle"
|
||||
app:tint="@color/color_accent_active"
|
||||
app:tint="@color/sel_accent_active"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/playback_skip_next"
|
||||
app:layout_constraintStart_toEndOf="@+id/playback_skip_next"
|
||||
app:layout_constraintTop_toTopOf="@+id/playback_skip_next" />
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
app:cardBackgroundColor="?attr/colorSurface"
|
||||
app:cardCornerRadius="0dp"
|
||||
app:cardElevation="0dp"
|
||||
app:strokeColor="@color/divider"
|
||||
app:strokeColor="@color/overlay_divider"
|
||||
app:strokeWidth="1dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
@ -167,7 +167,7 @@
|
|||
android:contentDescription="@string/desc_shuffle"
|
||||
android:onClick="@{() -> playbackModel.invertShuffleStatus()}"
|
||||
android:src="@drawable/ic_shuffle"
|
||||
app:tint="@color/color_accent_active"
|
||||
app:tint="@color/sel_accent_active"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/playback_skip_next"
|
||||
app:layout_constraintEnd_toEndOf="@+id/playback_song_duration"
|
||||
app:layout_constraintTop_toTopOf="@+id/playback_skip_next" />
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".ui.HeaderViewHolder">
|
||||
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
|
@ -13,8 +14,7 @@
|
|||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ui_header_dividers">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/header_title"
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
android:text="@{String.valueOf(song.track)}"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
android:textColor="?android:attr/textColorTertiary"
|
||||
android:textColor="@color/sel_accented_track"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
@ -35,6 +35,7 @@
|
|||
android:id="@+id/song_name"
|
||||
style="@style/Widget.TextView.Item.Primary"
|
||||
android:text="@{song.name}"
|
||||
android:textColor="@color/sel_accented_primary"
|
||||
app:layout_constraintBottom_toTopOf="@+id/song_duration"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/song_track"
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
<TextView
|
||||
android:id="@+id/album_name"
|
||||
style="@style/Widget.TextView.Item.Primary"
|
||||
android:textColor="@color/sel_accented_primary"
|
||||
android:text="@{album.name}"
|
||||
app:layout_constraintBottom_toTopOf="@+id/album_year"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
<TextView
|
||||
android:id="@+id/song_name"
|
||||
style="@style/Widget.TextView.Item.Primary"
|
||||
android:textColor="@color/sel_accented_primary"
|
||||
android:layout_marginEnd="@dimen/spacing_medium"
|
||||
android:text="@{song.name}"
|
||||
app:layout_constraintBottom_toTopOf="@+id/song_info"
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
<TextView
|
||||
android:id="@+id/song_name"
|
||||
style="@style/Widget.TextView.Item.Primary"
|
||||
android:textColor="@color/sel_accented_primary"
|
||||
android:layout_marginEnd="@dimen/spacing_medium"
|
||||
android:text="@{song.name}"
|
||||
app:layout_constraintBottom_toTopOf="@+id/song_info"
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="surface">@color/surface_night</color>
|
||||
<color name="divider">#3b3c3f</color>
|
||||
<color name="selection">#686868</color>
|
||||
<color name="inactive">#404040</color>
|
||||
<color name="control">#ffffff</color>
|
||||
<color name="nav_bar">#01151515</color>
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
<color name="surface_black">@android:color/black</color>
|
||||
|
||||
<color name="surface">@color/surface_day</color>
|
||||
<color name="selection">#ababab</color>
|
||||
<color name="control">#202020</color>
|
||||
<color name="divider">#cbcbcb</color>
|
||||
<color name="inactive">#c4c4c4</color>
|
||||
<color name="nav_bar">#01fafafa</color>
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<!-- Toolbar popup menu -->
|
||||
<style name="ThemeOverlay.ToolbarPopup" parent="ThemeOverlay.AppCompat.DayNight">
|
||||
<item name="android:colorBackground">?attr/colorSurface</item>
|
||||
<item name="colorControlHighlight">@color/selection</item>
|
||||
<item name="colorControlHighlight">@color/overlay_selection</item>
|
||||
</style>
|
||||
|
||||
<!-- Base custom dialog theme. Don't try to understand this. -->
|
||||
|
@ -31,7 +31,7 @@
|
|||
<!-- Normal DayNight dialog theme -->
|
||||
<style name="Theme.CustomDialog" parent="Theme.CustomDialog.Base">
|
||||
<item name="colorSurface">@color/surface</item>
|
||||
<item name="colorControlHighlight">@color/selection</item>
|
||||
<item name="colorControlHighlight">@color/overlay_selection</item>
|
||||
</style>
|
||||
|
||||
<!-- Black theme dialog theme -->
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
|
||||
<item name="colorSecondary">?attr/colorAccent</item>
|
||||
<item name="colorOnSecondary">?attr/colorSurface</item>
|
||||
|
||||
|
||||
<item name="colorControlNormal">@color/control</item>
|
||||
<item name="colorControlHighlight">@color/color_selection</item>
|
||||
<item name="colorControlHighlight">@color/overlay_selection</item>
|
||||
<item name="colorControlActivated">?attr/colorAccent</item>
|
||||
|
||||
<!-- Appearance -->
|
||||
|
|
|
@ -215,7 +215,7 @@
|
|||
</style>
|
||||
|
||||
<style name="Widget.Button.Vibrant.Secondary" parent="@style/Widget.Button.Vibrant.Base">
|
||||
<item name="strokeColor">@color/divider</item>
|
||||
<item name="strokeColor">@color/overlay_divider</item>
|
||||
<item name="strokeWidth">@dimen/size_stroke_small</item>
|
||||
<item name="rippleColor">?attr/colorControlHighlight</item>
|
||||
</style>
|
||||
|
|
Loading…
Reference in a new issue