Remove RecyclerViewBackgroundDrawable

This commit is contained in:
Wolf-Martell Montwé 2024-02-14 18:28:14 +01:00
parent 50341d0d73
commit db13bf2e93
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
4 changed files with 0 additions and 57 deletions

View file

@ -1,47 +0,0 @@
package com.fsck.k9.ui.helper
import android.graphics.Canvas
import android.graphics.ColorFilter
import android.graphics.Paint
import android.graphics.PixelFormat
import android.graphics.drawable.Drawable
import androidx.recyclerview.widget.RecyclerView
// Based on https://stackoverflow.com/a/49825927/1800174
class RecyclerViewBackgroundDrawable internal constructor(private val color: Int) : Drawable() {
private var recyclerView: RecyclerView? = null
private val paint: Paint = Paint().apply {
color = this@RecyclerViewBackgroundDrawable.color
}
fun attachTo(recyclerView: RecyclerView?) {
this.recyclerView = recyclerView
recyclerView?.background = this
}
override fun draw(canvas: Canvas) {
val recyclerView = recyclerView ?: return
if (recyclerView.childCount == 0) {
return
}
var bottom = recyclerView.getChildAt(recyclerView.childCount - 1).bottom
if (bottom >= recyclerView.bottom) {
bottom = recyclerView.bottom
}
canvas.drawRect(
recyclerView.left.toFloat(),
recyclerView.top.toFloat(),
recyclerView.right.toFloat(),
bottom.toFloat(),
paint,
)
}
override fun setAlpha(alpha: Int) = Unit
override fun setColorFilter(colorFilter: ColorFilter?) = Unit
override fun getOpacity(): Int = PixelFormat.OPAQUE
}

View file

@ -19,8 +19,6 @@ import app.k9mail.feature.launcher.FeatureLauncherActivity
import com.fsck.k9.Account import com.fsck.k9.Account
import com.fsck.k9.ui.R import com.fsck.k9.ui.R
import com.fsck.k9.ui.base.livedata.observeNotNull import com.fsck.k9.ui.base.livedata.observeNotNull
import com.fsck.k9.ui.helper.RecyclerViewBackgroundDrawable
import com.fsck.k9.ui.resolveColorAttribute
import com.fsck.k9.ui.settings.account.AccountSettingsActivity import com.fsck.k9.ui.settings.account.AccountSettingsActivity
import com.fsck.k9.view.DraggableFrameLayout import com.fsck.k9.view.DraggableFrameLayout
import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.FastAdapter
@ -72,9 +70,6 @@ class SettingsListFragment : Fragment(), ItemTouchCallback {
recyclerView.adapter = settingsListAdapter recyclerView.adapter = settingsListAdapter
recyclerView.layoutManager = LinearLayoutManager(context) recyclerView.layoutManager = LinearLayoutManager(context)
touchHelper.attachToRecyclerView(recyclerView) touchHelper.attachToRecyclerView(recyclerView)
val recyclerViewBackgroundColor = recyclerView.context.theme.resolveColorAttribute(R.attr.behindRecyclerView)
RecyclerViewBackgroundDrawable(recyclerViewBackgroundColor).attachTo(recyclerView)
} }
private fun populateSettingsList() { private fun populateSettingsList() {

View file

@ -131,8 +131,6 @@
<attr name="openpgp_blue" format="reference|color" /> <attr name="openpgp_blue" format="reference|color" />
<attr name="openpgp_grey" format="reference|color" /> <attr name="openpgp_grey" format="reference|color" />
<attr name="openpgp_dark_grey" format="reference|color" /> <attr name="openpgp_dark_grey" format="reference|color" />
<attr name="behindRecyclerView" format="reference|color" />
</declare-styleable> </declare-styleable>
<declare-styleable name="FoldableLinearLayout"> <declare-styleable name="FoldableLinearLayout">

View file

@ -198,7 +198,6 @@
<item name="materialDrawerStyle">@style/Widget.MaterialDrawerStyle.K9.Light</item> <item name="materialDrawerStyle">@style/Widget.MaterialDrawerStyle.K9.Light</item>
<item name="materialDrawerHeaderStyle">@style/Widget.MaterialDrawerHeaderStyle.K9.Light</item> <item name="materialDrawerHeaderStyle">@style/Widget.MaterialDrawerHeaderStyle.K9.Light</item>
<item name="behindRecyclerView">#F0F0F0</item>
<item name="snackbarButtonStyle">@style/Widget.K9.Button.Snackbar</item> <item name="snackbarButtonStyle">@style/Widget.K9.Button.Snackbar</item>
</style> </style>
@ -403,8 +402,6 @@
<item name="materialDrawerStyle">@style/Widget.MaterialDrawerStyle.K9.Dark</item> <item name="materialDrawerStyle">@style/Widget.MaterialDrawerStyle.K9.Dark</item>
<item name="materialDrawerHeaderStyle">@style/Widget.MaterialDrawerHeaderStyle.K9.Dark</item> <item name="materialDrawerHeaderStyle">@style/Widget.MaterialDrawerHeaderStyle.K9.Dark</item>
<item name="behindRecyclerView">#202020</item>
<item name="snackbarButtonStyle">@style/Widget.K9.Button.Snackbar</item> <item name="snackbarButtonStyle">@style/Widget.K9.Button.Snackbar</item>
</style> </style>