fix: Clear two layers stale state from highlight decorator (#6819)

Signed-off-by: Pun Butrach <pun.butrach@gmail.com>
This commit is contained in:
Pun Butrach authored and GitHub committed 2026-05-31 13:58:13 +00:00
1 parent 9382280d9a
commit 3e52c8a5ab
7 files changed
+41 -31

No files matched your search

@@ -219,6 +219,10 @@ class AllAppsSearchInput(context: Context, attrs: AttributeSet?) :
input.setHint("")
hint.text = ""
}
if (::appsView.isInitialized) {
appsView.mSearchRecyclerView.invalidate()
}
}
input.addTextChangedListener(
@@ -66,7 +66,6 @@ class SearchResultIcon(context: Context, attrs: AttributeSet?) :
}
override fun bind(target: SearchTargetCompat, shortcuts: List<SearchTargetCompat>) {
if (boundId == target.id) return
boundId = target.id
flags = getFlags(target.extras)
reset()
@@ -83,7 +82,7 @@ class SearchResultIcon(context: Context, attrs: AttributeSet?) :
target.shortcutInfo != null -> {
allowLongClick = true
bindFromShortcutInfo(target.shortcutInfo)
bindFromShortcutInfo(target.id, target.shortcutInfo)
}
else -> {
@@ -150,9 +149,14 @@ class SearchResultIcon(context: Context, attrs: AttributeSet?) :
}
notifyApplied(info)
if (bindIcon) {
val targetId = boundId
Executors.MODEL_EXECUTOR.handler.postAtFrontOfQueue {
populateSearchActionItemInfo(target, info)
runOnMainThread { applyFromItemInfoWithIcon(info) }
runOnMainThread {
if (boundId == targetId) {
applyFromItemInfoWithIcon(info)
}
}
}
}
}
@@ -176,7 +180,7 @@ class SearchResultIcon(context: Context, attrs: AttributeSet?) :
notifyApplied(appInfo)
}
private fun bindFromShortcutInfo(shortcutInfo: ShortcutInfo) {
private fun bindFromShortcutInfo(targetId: String, shortcutInfo: ShortcutInfo) {
val si = WorkspaceItemInfo(shortcutInfo, launcher)
si.container = LauncherSettings.Favorites.CONTAINER_ALL_APPS
applyFromWorkspaceItem(si)
@@ -184,7 +188,11 @@ class SearchResultIcon(context: Context, attrs: AttributeSet?) :
val cache = LauncherAppState.getInstance(launcher).iconCache
Executors.MODEL_EXECUTOR.handler.postAtFrontOfQueue {
cache.getShortcutIcon(si, shortcutInfo)
runOnMainThread { applyFromWorkspaceItem(si) }
runOnMainThread {
if (boundId == targetId) {
applyFromWorkspaceItem(si)
}
}
}
}
@@ -31,7 +31,6 @@ class SearchResultIconRow(context: Context, attrs: AttributeSet?) :
private var delimiter: View? = null
private lateinit var shortcutIcons: Array<SearchResultIcon>
private var boundId = ""
private var flags = 0
override fun onFinishInflate() {
@@ -78,8 +77,6 @@ class SearchResultIconRow(context: Context, attrs: AttributeSet?) :
}
override fun bind(target: SearchTargetCompat, shortcuts: List<SearchTargetCompat>) {
if (boundId == target.id) return
boundId = target.id
flags = getFlags(target.extras)
icon.bind(target) {
@@ -82,7 +82,8 @@ class SearchResultRightLeftIcon(context: Context, attrs: AttributeSet?) :
this.layoutParams = layoutParams
}
override val isQuickLaunch: Boolean get() = hasFlag(flags, SearchResultView.FLAG_QUICK_LAUNCH)
override val isQuickLaunch: Boolean
get() = hasFlag(flags, SearchResultView.FLAG_QUICK_LAUNCH)
override val titleText: CharSequence? get() = title.text
@@ -97,6 +98,7 @@ class SearchResultRightLeftIcon(context: Context, attrs: AttributeSet?) :
target: SearchTargetCompat,
shortcuts: List<SearchTargetCompat>,
) {
flags = getFlags(target.extras)
title.text = target.searchAction?.title
val isNewFile = target.resultType == SearchTargetCompat.RESULT_TYPE_FILE_TILE &&
target.layoutType == LayoutType.THUMBNAIL
@@ -41,7 +41,12 @@ class LawnchairSearchAdapterProvider(
private var quickLaunchItem: SearchResultView? = null
set(value) {
field = value
appsView.searchUiManager.setFocusedResultTitle(field?.titleText, field?.titleText, true)
appsView.searchUiManager.setFocusedResultTitle(
field?.titleText,
field?.titleText,
field != null,
)
appsView.mSearchRecyclerView.invalidate()
}
override fun isViewSupported(viewType: Int): Boolean = layoutIdMap.contains(viewType)
@@ -91,6 +96,11 @@ class LawnchairSearchAdapterProvider(
override fun getHighlightedItem() = quickLaunchItem as View?
override fun clearHighlightedItem() {
super.clearHighlightedItem()
quickLaunchItem = null
}
override fun getDecorator() = decorator
companion object {
@@ -1,6 +1,7 @@
package app.lawnchair.search.adapter
import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.drawable.InsetDrawable
import android.graphics.drawable.RippleDrawable
import android.graphics.drawable.ShapeDrawable
@@ -8,6 +9,7 @@ import android.graphics.drawable.shapes.RoundRectShape
import android.view.View
import app.lawnchair.allapps.views.SearchItemBackground
import app.lawnchair.search.LawnchairSearchAdapterProvider
import com.android.launcher3.R
import com.android.launcher3.allapps.BaseAllAppsAdapter
data class SearchAdapterItem(
@@ -28,26 +30,13 @@ data class SearchAdapterItem(
fun setRippleEffect(child: View) {
val shape = RoundRectShape(background?.cornerRadii, null, null)
val shapeDrawable = ShapeDrawable(shape)
val colorDefault = background?.groupHighlight ?: 0
val colorPressed = background?.focusHighlight ?: 0
val colorStateList = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_pressed),
intArrayOf(-android.R.attr.state_pressed),
),
intArrayOf(
colorPressed,
colorDefault,
),
)
shapeDrawable.paint.color = colorDefault
val inset = 3
val insetDrawable = InsetDrawable(shapeDrawable, 0, inset, 0, inset)
val rippleDrawable = RippleDrawable(colorStateList, insetDrawable, null)
child.background = rippleDrawable
val maskDrawable = ShapeDrawable(shape).apply {
paint.color = Color.WHITE
}
val rippleColor = background?.focusHighlight ?: background?.groupHighlight ?: 0
val inset = child.resources.getDimensionPixelSize(R.dimen.search_decoration_padding)
val insetMask = InsetDrawable(maskDrawable, 0, inset, 0, inset)
child.background = RippleDrawable(ColorStateList.valueOf(rippleColor), null, insetMask)
}
companion object {
@@ -1783,7 +1783,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
new ViewGroupFocusHelper(mRecyclerView)) : new FocusedItemDecorator(
mRecyclerView);
mRecyclerView.addItemDecoration(focusedItemDecorator);
// LC-Note: This is needed for highlight focused app decoration, this has some problem of it own but purely visual.
// LC-Note: This is needed for highlight decoration
if (isSearch()) {
RecyclerView.ItemDecoration searchDecorator = getMainAdapterProvider().getDecorator();
if (searchDecorator != null) {