ui: refactor shadow management

Make the shadow disabling workaround an XML style.

Doing it this way is more elegant than disabling it in-code.
This commit is contained in:
OxygenCobalt 2022-08-09 09:07:25 -06:00
parent bcc16fb88c
commit 83d1e4eae4
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
6 changed files with 24 additions and 18 deletions

View file

@ -2,6 +2,9 @@
## dev ## dev
#### What's New
- Detail UI now displays the type of item shown (ex. the release type)
#### What's Fixed #### What's Fixed
- Fixed incorrect font being used in the queue title - Fixed incorrect font being used in the queue title
- Fixed missing fast scroll indicator with date added scrolling - Fixed missing fast scroll indicator with date added scrolling

View file

@ -77,14 +77,17 @@ class AlbumListFragment : HomeListFragment<Album>() {
is Sort.Mode.ByCount -> album.songs.size.toString() is Sort.Mode.ByCount -> album.songs.size.toString()
// Last added -> Format as date // Last added -> Format as date
is Sort.Mode.ByDateAdded -> is Sort.Mode.ByDateAdded -> {
(album.songs.minOf { it.dateAdded } * 1000).let { val dateAddedMillis = album.dateAdded * 1000
// Emulate formatDateTime with our own formatter instance to save memory. formatterSb.setLength(0)
formatterSb.setLength(0) DateUtils.formatDateRange(
DateUtils.formatDateRange( context,
context, formatter, it, it, DateUtils.FORMAT_ABBREV_ALL) formatter,
.toString() dateAddedMillis,
} dateAddedMillis,
DateUtils.FORMAT_ABBREV_ALL)
.toString()
}
// Unsupported sort, error gracefully // Unsupported sort, error gracefully
else -> null else -> null

View file

@ -19,7 +19,6 @@ package org.oxycblt.auxio.ui
import android.content.Context import android.content.Context
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.Build
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -67,16 +66,8 @@ abstract class AuxioSheetBehavior<V : View>(context: Context, attributeSet: Attr
if (!setup) { if (!setup) {
child.apply { child.apply {
translationZ = context.getDimen(R.dimen.elevation_normal)
background = createBackground(context) background = createBackground(context)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
// Shadows aren't disabled by default, do that.
val transparent =
context.getColorCompat(android.R.color.transparent).defaultColor
outlineAmbientShadowColor = transparent
outlineSpotShadowColor = transparent
}
setOnApplyWindowInsetsListener(::applyWindowInsets) setOnApplyWindowInsetsListener(::applyWindowInsets)
} }

View file

@ -21,6 +21,7 @@
android:id="@+id/playback_sheet" android:id="@+id/playback_sheet"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
style="@style/Widget.Auxio.DisableDropShadows"
app:layout_behavior="org.oxycblt.auxio.playback.PlaybackSheetBehavior"> app:layout_behavior="org.oxycblt.auxio.playback.PlaybackSheetBehavior">
<androidx.fragment.app.FragmentContainerView <androidx.fragment.app.FragmentContainerView
@ -41,6 +42,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
style="@style/Widget.Auxio.DisableDropShadows"
app:layout_behavior="org.oxycblt.auxio.playback.queue.QueueSheetBehavior"> app:layout_behavior="org.oxycblt.auxio.playback.queue.QueueSheetBehavior">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout

View file

@ -2,6 +2,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
style="@style/Widget.Auxio.DisableDropShadows"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">

View file

@ -93,6 +93,12 @@
<item name="android:paddingBottom">@dimen/recycler_fab_space_normal</item> <item name="android:paddingBottom">@dimen/recycler_fab_space_normal</item>
</style> </style>
<style name="Widget.Auxio.DisableDropShadows" parent="">
<!-- API 28+ Only -->
<item name="android:outlineAmbientShadowColor" tools:ignore="NewApi">@android:color/transparent</item>
<item name="android:outlineSpotShadowColor" tools:ignore="NewApi">@android:color/transparent</item>
</style>
<style name="ThemeOverlay.Accent" parent=""> <style name="ThemeOverlay.Accent" parent="">
<item name="colorOnPrimary">?attr/colorSurface</item> <item name="colorOnPrimary">?attr/colorSurface</item>
</style> </style>