From 64e20c90cc69ee4f8bb5a854e4fe6317d3c0791a Mon Sep 17 00:00:00 2001 From: MrSluffy Date: Fri, 3 Apr 2026 09:32:56 +0800 Subject: [PATCH] fix: clear pressed icon state on focus/launch Add handling to fully clear press visuals when focus returns or a launch transition ends. BubbleTextView now overrides onWindowFocusChanged to call a new clearPressedIconState() method, which clears framework pressed/stay-pressed state and resets the icon tap scale. Launcher was updated to call the new method reference instead of only clearing stay-pressed, ensuring icons match neighbors and covering ordering gaps when resume callbacks run before window focus is restored. --- src/com/android/launcher3/BubbleTextView.java | 19 +++++++++++++++++++ src/com/android/launcher3/Launcher.java | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index ada16f5737..6b731f4f55 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -724,11 +724,30 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, } } + @Override + public void onWindowFocusChanged(boolean hasWindowFocus) { + super.onWindowFocusChanged(hasWindowFocus); + // Resume callbacks can run before the window is focused again (e.g. back / predictive + // back). Clearing when focus returns covers that ordering gap. + if (hasWindowFocus) { + clearPressedIconState(); + } + } + public void clearPressedBackground() { setPressed(false); setStayPressed(false); } + /** + * Clears framework pressed state, synthetic stay-pressed, and {@link FastBitmapDrawable} tap + * scale. Use when a launch transition ends so the icon matches neighbors again. + */ + public void clearPressedIconState() { + clearPressedBackground(); + resetIconScale(); + } + @Override public boolean onKeyUp(int keyCode, KeyEvent event) { // Unlike touch events, keypress event propagate pressed state change immediately, diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 6ecbcf766f..a1b5c6b978 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2120,7 +2120,7 @@ public class Launcher extends StatefulActivity // state when we return to launcher. BubbleTextView btv = (BubbleTextView) v; btv.setStayPressed(true); - result.add(() -> btv.setStayPressed(false)); + result.add(btv::clearPressedIconState); } return result; }