From 1826ae32150455dea85c0def4a9adf3ba74bd8ff Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Sun, 12 Feb 2023 21:45:47 -0700 Subject: [PATCH] deps: update to mdc 1.8.0-alpha01 FINALLY update to MDC 1.7.0. After over half a year. I have been continually blocked by doing this due to this absurd ripple bug that was so continually frustrating. Today, I finally figred out how to hack a fix in by using R E F L E C T I O N and manually disabling the bugged code path since google apparently can't be bothered to fix it. Now, you might wonder why I didn't update to 1.8.0. That is because there is ANOTHER RIPPLE BUG. THIS TIME WITH THE TAB LAYOUT. AND ONLY IF IT'S IN A COLLAPSING TOOLBAR LAYOUT. Can't wait to finally use the new 1.8.0 features in December! --- app/build.gradle | 12 +++--- .../oxycblt/auxio/music/model/MusicImpl.kt | 28 +++++++------- .../org/oxycblt/auxio/music/system/Indexer.kt | 4 ++ .../playback/ui/AnimatedMaterialButton.kt | 3 +- .../settings/ui/IntListPreferenceDialog.kt | 13 +++++++ .../auxio/ui/RippleFixMaterialButton.kt | 38 +++++++++++++++++++ .../auxio/ui/ViewBindingDialogFragment.kt | 12 ++++++ .../org/oxycblt/auxio/util/FrameworkUtil.kt | 12 ++++++ .../layout-h480dp/fragment_playback_panel.xml | 8 ++-- .../main/res/layout-h600dp/item_detail.xml | 4 +- app/src/main/res/layout-land/item_detail.xml | 4 +- .../fragment_playback_panel.xml | 8 ++-- .../main/res/layout-sw600dp/item_detail.xml | 4 +- .../main/res/layout-sw840dp/item_detail.xml | 4 +- .../res/layout-v23/view_preference_switch.xml | 10 ----- app/src/main/res/layout/dialog_music_dirs.xml | 6 +-- app/src/main/res/layout/fragment_home.xml | 5 +-- .../main/res/layout/fragment_playback_bar.xml | 4 +- .../res/layout/fragment_playback_panel.xml | 8 ++-- app/src/main/res/layout/item_accent.xml | 2 +- app/src/main/res/layout/item_album_song.xml | 3 +- app/src/main/res/layout/item_detail.xml | 4 +- app/src/main/res/layout/item_music_dir.xml | 2 +- app/src/main/res/layout/item_parent.xml | 2 +- app/src/main/res/layout/item_queue_song.xml | 2 +- app/src/main/res/layout/item_song.xml | 2 +- app/src/main/res/layout/item_sort_header.xml | 2 +- app/src/main/res/layout/item_tab.xml | 2 +- .../res/layout/view_preference_switch.xml | 5 ++- app/src/main/res/values/styles_ui.xml | 2 - app/src/main/res/values/typography.xml | 8 ++-- 31 files changed, 146 insertions(+), 77 deletions(-) create mode 100644 app/src/main/java/org/oxycblt/auxio/ui/RippleFixMaterialButton.kt delete mode 100644 app/src/main/res/layout-v23/view_preference_switch.xml diff --git a/app/build.gradle b/app/build.gradle index cd4a767d1..d48bce1cd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -67,7 +67,7 @@ dependencies { // General // 1.4.0 is used in order to avoid a ripple bug in material components - implementation "androidx.appcompat:appcompat:1.4.0" + implementation "androidx.appcompat:appcompat:1.6.1" implementation "androidx.core:core-ktx:1.9.0" implementation "androidx.activity:activity-ktx:1.6.1" implementation "androidx.fragment:fragment-ktx:1.5.5" @@ -113,14 +113,16 @@ dependencies { implementation fileTree(dir: "libs", include: ["extension-*.aar"]) // Image loading - implementation "io.coil-kt:coil-base:2.1.0" + implementation "io.coil-kt:coil-base:2.2.0" // Material - // Locked below 1.7.0-alpha03 to avoid the same ripple bug - implementation "com.google.android.material:material:1.7.0-alpha02" + // TODO: Stuck on 1.8.0-alpha01 until ripple bug with tab layout can be worked around + // TODO: Exactly figure out the conditions that the 1.7.0 ripple bug occurred so you can just + // PR a fix. + implementation "com.google.android.material:material:1.8.0-alpha01" // Dependency Injection - def dagger_version = "2.40" + def dagger_version = "2.44.2" implementation "com.google.dagger:dagger:$dagger_version" kapt "com.google.dagger:dagger-compiler:$dagger_version" implementation "com.google.dagger:hilt-android:$hilt_version" diff --git a/app/src/main/java/org/oxycblt/auxio/music/model/MusicImpl.kt b/app/src/main/java/org/oxycblt/auxio/music/model/MusicImpl.kt index 736d7cb1f..e863b8003 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/model/MusicImpl.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/model/MusicImpl.kt @@ -143,8 +143,8 @@ class SongImpl(rawSong: RawSong, musicSettings: MusicSettings) : Song { override fun resolveGenreContents(context: Context) = resolveNames(context, genres) /** - * The [RawAlbum] instances collated by the [Song]. This can be used to group [Song]s - * into an [Album]. + * The [RawAlbum] instances collated by the [Song]. This can be used to group [Song]s into an + * [Album]. */ val rawAlbum = RawAlbum( @@ -167,8 +167,8 @@ class SongImpl(rawSong: RawSong, musicSettings: MusicSettings) : Song { rawIndividualArtists.ifEmpty { rawAlbumArtists }.ifEmpty { listOf(RawArtist()) } /** - * The [RawGenre] instances collated by the [Song]. This can be used to group up [Song]s - * into a [Genre]. ID3v2 Genre names are automatically converted to their resolved names. + * The [RawGenre] instances collated by the [Song]. This can be used to group up [Song]s into a + * [Genre]. ID3v2 Genre names are automatically converted to their resolved names. */ val rawGenres = rawSong.genreNames @@ -233,8 +233,8 @@ class SongImpl(rawSong: RawSong, musicSettings: MusicSettings) : Song { /** * Library-backed implementation of [Album]. * @param rawAlbum The [RawAlbum] to derive the member data from. - * @param songs The [Song]s that are a part of this [Album]. These items will be linked to - * this [Album]. + * @param songs The [Song]s that are a part of this [Album]. These items will be linked to this + * [Album]. * @author Alexander Capehart (OxygenCobalt) */ class AlbumImpl(val rawAlbum: RawAlbum, override val songs: List) : Album { @@ -334,9 +334,9 @@ class AlbumImpl(val rawAlbum: RawAlbum, override val songs: List) : Al /** * Library-backed implementation of [Artist]. * @param rawArtist The [RawArtist] to derive the member data from. - * @param songAlbums A list of the [Song]s and [Album]s that are a part of this [Artist] - * , either through artist or album artist tags. Providing [Song]s to the artist is optional. - * These instances will be linked to this [Artist]. + * @param songAlbums A list of the [Song]s and [Album]s that are a part of this [Artist] , either + * through artist or album artist tags. Providing [Song]s to the artist is optional. These instances + * will be linked to this [Artist]. * @author Alexander Capehart (OxygenCobalt) */ class ArtistImpl(private val rawArtist: RawArtist, songAlbums: List) : Artist { @@ -404,8 +404,8 @@ class ArtistImpl(private val rawArtist: RawArtist, songAlbums: List) : Ar /** * Returns the original position of this [Artist]'s [RawArtist] within the given [RawArtist] - * list. This can be used to create a consistent ordering within child [Artist] lists based - * on the original tag order. + * list. This can be used to create a consistent ordering within child [Artist] lists based on + * the original tag order. * @param rawArtists The [RawArtist] instances to check. It is assumed that this [Artist]'s * [RawArtist] will be within the list. * @return The index of the [Artist]'s [RawArtist] within the list. @@ -467,9 +467,9 @@ class GenreImpl(private val rawGenre: RawGenre, override val songs: List. + */ + +package org.oxycblt.auxio.ui + +import android.content.Context +import android.util.AttributeSet +import androidx.annotation.AttrRes +import com.google.android.material.button.MaterialButton +import org.oxycblt.auxio.util.fixDoubleRipple + +/** + * Fixes an issue where double ripples appear on [MaterialButton] from AppCompat 1.5 afterwards due + * to a currently unfixed change. + * @author Alexander Capehart (OxygenCobalt) + */ +open class RippleFixMaterialButton +@JvmOverloads +constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr: Int = 0) : + MaterialButton(context, attrs, defStyleAttr) { + init { + fixDoubleRipple() + } +} diff --git a/app/src/main/java/org/oxycblt/auxio/ui/ViewBindingDialogFragment.kt b/app/src/main/java/org/oxycblt/auxio/ui/ViewBindingDialogFragment.kt index ae53a8a7f..1b9a5eb47 100644 --- a/app/src/main/java/org/oxycblt/auxio/ui/ViewBindingDialogFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/ui/ViewBindingDialogFragment.kt @@ -22,9 +22,11 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.appcompat.app.AlertDialog +import androidx.appcompat.widget.AppCompatButton import androidx.fragment.app.DialogFragment import androidx.viewbinding.ViewBinding import com.google.android.material.dialog.MaterialAlertDialogBuilder +import org.oxycblt.auxio.util.fixDoubleRipple import org.oxycblt.auxio.util.logD import org.oxycblt.auxio.util.unlikelyToBeNull @@ -102,6 +104,16 @@ abstract class ViewBindingDialogFragment : DialogFragment() { logD("Fragment created") } + override fun onStart() { + super.onStart() + + (requireDialog() as AlertDialog).apply { + (getButton(AlertDialog.BUTTON_NEUTRAL) as AppCompatButton).fixDoubleRipple() + (getButton(AlertDialog.BUTTON_POSITIVE) as AppCompatButton).fixDoubleRipple() + (getButton(AlertDialog.BUTTON_NEGATIVE) as AppCompatButton).fixDoubleRipple() + } + } + final override fun onDestroyView() { super.onDestroyView() onDestroyBinding(unlikelyToBeNull(_binding)) diff --git a/app/src/main/java/org/oxycblt/auxio/util/FrameworkUtil.kt b/app/src/main/java/org/oxycblt/auxio/util/FrameworkUtil.kt index abbe1f474..e81dc11d3 100644 --- a/app/src/main/java/org/oxycblt/auxio/util/FrameworkUtil.kt +++ b/app/src/main/java/org/oxycblt/auxio/util/FrameworkUtil.kt @@ -24,6 +24,7 @@ import android.os.Build import android.view.View import android.view.WindowInsets import androidx.annotation.RequiresApi +import androidx.appcompat.widget.AppCompatButton import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.core.graphics.Insets import androidx.core.graphics.drawable.DrawableCompat @@ -106,6 +107,17 @@ val ViewBinding.context: Context */ fun RecyclerView.canScroll() = computeVerticalScrollRange() > height +/** + * Fix the double ripple that appears in MaterialButton instances due to an issue with AppCompat 1.5 + * or higher. + */ +fun AppCompatButton.fixDoubleRipple() { + AppCompatButton::class.java.getDeclaredField("mBackgroundTintHelper").apply { + isAccessible = true + set(this@fixDoubleRipple, null) + } +} + /** * Get the [CoordinatorLayout.Behavior] of a [View], or null if the [View] is not part of a * [CoordinatorLayout] or does not have a [CoordinatorLayout.Behavior]. diff --git a/app/src/main/res/layout-h480dp/fragment_playback_panel.xml b/app/src/main/res/layout-h480dp/fragment_playback_panel.xml index 6ba7e9b53..a7406768f 100644 --- a/app/src/main/res/layout-h480dp/fragment_playback_panel.xml +++ b/app/src/main/res/layout-h480dp/fragment_playback_panel.xml @@ -87,7 +87,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - -