Skip to content

fix: Icons not refreshing after changing icon preferences - #6738

Merged
validcube merged 4 commits into
LawnchairLauncher:16-devfrom
wellorbetter:fix/icon-cache-freshness-id
Jun 2, 2026
Merged

fix: Icons not refreshing after changing icon preferences#6738
validcube merged 4 commits into
LawnchairLauncher:16-devfrom
wellorbetter:fix/icon-cache-freshness-id

Conversation

@wellorbetter

@wellorbetter wellorbetter commented May 11, 2026

Copy link
Copy Markdown
Contributor

Description

Changing any icon-related preference (Icon Pack, Themed icon source, Themed icons scope, Force monochrome, etc.) fails to refresh drawer/workspace icons. Once app_icons.db entries are generated, no preference change invalidates them — icons stay stale until pm clear or versionCode bumps.

Root cause: IconProvider.getStateForApp() (used as the DB freshnessId) only encodes system state and appInfo.sourceDir. Lawnchair's own preferences that drive icon rendering are not included, so IconCacheUpdateHandler always considers cached entries up-to-date.

Fix: override getStateForApp() in LawnchairIconProvider to append a fingerprint of all Lawnchair prefs that affect rendering.

Fixes #6725
Fixes #6731

Reproduction (100% reliable after pm clear)

  1. Home Settings → General → Icons
  2. Themed icons → Home screen
  3. Themed icon source → Lawnicons
  4. Enable Force monochrome
  5. Icon Pack → LawniconsDB poisoning point (LoaderTask writes Lawnicons monochrome BitmapInfo to DB)
  6. Themed icons → Home screen and app drawer
  7. Themed icons → Home screenbug visible (drawer now uses the poisoned main bitmap)
  8. Any subsequent pref change (clear Icon Pack, disable Force monochrome, restart launcher) has no effect on drawer.

Why it's deterministic

PreferenceManager.reloadIcons only calls iconCache.clearMemoryCache(). The DB is untouched. The moment model.reloadIfActive() triggers LoaderTask, IconCacheUpdateHandler compares:

dbRow.freshnessId == iconProvider.getStateForApp(app)

Since getStateForApp() never sees Lawnchair prefs, both sides stay equal across steps 5→7→8, entries are considered fresh, and getIcon() is never re-invoked. The poisoned bitmap is reloaded from DB into memory — "refresh" is a no-op.

Why extending getStateForApp over clearing DB

  • Per-entry invalidation via AOSP's existing mechanism, no lock/race concerns.
  • Only affected apps re-render on pref change (vs wholesale DB clear re-rendering every icon).
  • Adding a new pref that affects rendering later only requires appending one line to getStateForApp.

One-time cost: existing users' DB entries all lack the |lc: suffix, so the first post-upgrade LoaderTask re-generates every icon once. Steady-state afterward is per-app on-demand.

Testing

  1. adb shell pm clear app.lawnchair then repro steps 1–7 above
  2. Before fix: drawer stuck monochrome, unrecoverable by any pref
  3. After fix: drawer icons refresh immediately on pref change

Type of change

Bug fix (A non-breaking change that fixes an issue)
New feature (A non-breaking change that adds functionality)
Breaking change (A fix or feature that would cause existing functionality to not work as expected)
Refactor (A code change that neither fixes a bug nor adds a feature)
Performance (A code change that improves performance)
Style (Code style changes)
Docs (Changes to documentation)
Chore (Changes to the build process or other tooling)

Summary by CodeRabbit

  • Refactor
    • Improved icon theming state so the launcher consistently tracks and applies the selected icon pack, themed-icon source, themed-icons toggle, drawer themed-icons toggle, monochrome forcing, and background tinting preference — resulting in more reliable and predictable icon theming across the UI.

@coderabbitai

coderabbitai Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR changes LawnchairIconProvider to compute themedIconsEnabled from preferences and overrides getStateForApp(ApplicationInfo?) to append an lc: segment encoding Lawnchair icon/theming preferences (icon pack, themed icon source, themed-icons enablement for home/drawer, forced monochrome, and icon-pack background tinting) to the base state string.

Changes

Icon state tracking

Layer / File(s) Summary
Icon theming state generation
lawnchair/src/app/lawnchair/icons/LawnchairIconProvider.kt
themedIconsEnabled changed to a computed getter reading prefs.themedIcons. getStateForApp(info: ApplicationInfo?) is overridden to return super.getStateForApp(info) plus an lc: suffix that serializes icon pack and themed-icon-related preferences (themed icon source, home/drawer themed flags, force monochrome, tint background flag).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

bug-fix

Suggested reviewers

  • MrSluffy
  • validcube
  • yasanglass

Poem

🐰 I nibble prefs and spin a little thread,
lc: tucked in state so icons stay ahead,
Packs and tints and monochrome delight,
Home and drawer now follow the light,
Hop—refresh—icons bloom anew tonight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 10.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description includes a detailed summary, root cause analysis, reproduction steps, reasoning, and testing plan, comprehensively covering all relevant aspects.
Linked Issues check ✅ Passed The PR implementation directly addresses both linked issues by overriding getStateForApp() to include Lawnchair preferences in the freshnessId, enabling proper per-app cache invalidation and icon refresh on preference changes.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the icon cache freshness issue; only LawnchairIconProvider is modified to override getStateForApp() and change themedIconsEnabled to a computed getter, with no extraneous modifications.
Title check ✅ Passed The title 'fix: Icons not refreshing after changing icon preferences' accurately describes the main bug being fixed—icons not refreshing when icon preferences change—which is the core purpose of overriding getStateForApp() to encode Lawnchair preferences into the cache freshnessId.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@validcube

validcube commented Jun 2, 2026

Copy link
Copy Markdown
Member

Hello, is this PR finish? Looking forward to merge this when it's ready.

@wellorbetter
wellorbetter marked this pull request as ready for review June 2, 2026 12:46

@wellorbetter wellorbetter left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Root cause: IconProvider.getStateForApp() — used as the DB freshnessId — only encodes system state and APK path.Lawnchair's own icon-affecting preferences (icon pack, themed icons, force monochrome, etc.) are not part of the key. Once a bitmap is written to app_icons.db, any subsequent preference change produces the same freshnessId, so IconCacheUpdateHandler always considers entries fresh and never re-invokes getIcon().

Fix: Override getStateForApp() in LawnchairIconProvider to append a fingerprint of all Lawnchair prefs that influence icon rendering. A preference change now produces a different freshnessId → AOSP's existing per-entry freshness check invalidates stale rows → icons re-render on demand.

@wellorbetter

Copy link
Copy Markdown
Contributor Author

Hello, is this PR finish? Looking forward to merge this when it's ready.

Hey, yes it's ready — no further changes planned. Feel free to merge when convenient. Sorry for the slow response, been busy with work lately.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lawnchair/src/app/lawnchair/icons/LawnchairIconProvider.kt`:
- Around line 185-194: The cached boolean themedIconsEnabled is stale when prefs
change; replace the frozen field with a dynamic property so reads always call
prefs.themedIcons.get() (e.g., change the private val themedIconsEnabled =
prefs.themedIcons.get() to a getter-style property), ensuring getIcon and the
themeMap getter observe preference changes the same way getStateForApp does;
update only the themedIconsEnabled declaration so all uses (getIcon, themeMap,
etc.) read the current prefs.themedIcons.get().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0333212e-b9e3-4901-8adb-8f3cf7692be1

📥 Commits

Reviewing files that changed from the base of the PR and between b26a487 and 0edc353.

📒 Files selected for processing (1)
  • lawnchair/src/app/lawnchair/icons/LawnchairIconProvider.kt

Comment thread lawnchair/src/app/lawnchair/icons/LawnchairIconProvider.kt
@validcube

Copy link
Copy Markdown
Member

Hello, is this PR finish? Looking forward to merge this when it's ready.

Hey, yes it's ready — no further changes planned. Feel free to merge when convenient. Sorry for the slow response, been busy with work lately.

No worries. I'll approve and merge your PR now.

@coderabbitai
coderabbitai Bot requested a review from validcube June 2, 2026 12:55
@validcube validcube changed the title fix: icons not refreshing after changing icon preferences fix: Icons not refreshing after changing icon preferences Jun 2, 2026
@validcube
validcube enabled auto-merge (squash) June 2, 2026 12:55
@validcube
validcube merged commit fc32f2e into LawnchairLauncher:16-dev Jun 2, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

icon changes are not being applied ​[Lawn16] Themed icons applied to App Drawer and animation clipping with System Icons

2 participants