Compare commits

..

No commits in common. "7f2c1e19df7b2732f79ad579339c2dc4213d401a" and "28868871469a9403f7a7dad29f7e98174e09f723" have entirely different histories.

8 changed files with 19 additions and 188 deletions

View File

@ -1,35 +0,0 @@
{
"intent": "Stop pubspec.yaml's adaptive_icon_background from drifting from style.BACKGROUND -- it just did, across all 6 apps, and the drift was invisible until a physical device check.",
"scope": [
"python_pkg/app_icons/generate.py",
"python_pkg/app_icons/tests/test_generate.py"
],
"changes": [
"Added sync_pubspec_background(app): rewrites pubspec.yaml's adaptive_icon_background line in place to match style.BACKGROUND, called automatically from run_flutter_launcher_icons before invoking the dart tool",
"Root cause found during the warm-palette rollout: style.py's BACKGROUND was updated, but each app's pubspec.yaml carries its own independent adaptive_icon_background literal (flutter_launcher_icons' own config format) that nothing kept in sync -- all 6 apps stayed on the old value even though every generated PNG asset was correct. Android's actual home-screen icon is the adaptive icon (background color + foreground drawable), not the legacy ic_launcher.png mipmap, so this was invisible in file-byte checks and only showed up on the physical device"
],
"verification": [
{
"command": "python3 -m pytest python_pkg/app_icons/tests/ -q --no-cov",
"result": "pass",
"evidence": "43 passed (up from 39; 4 new tests for sync_pubspec_background)"
},
{
"command": "python3 -m pytest python_pkg/app_icons/tests/ --cov=python_pkg.app_icons.generate --cov-branch --cov-report=term-missing --no-cov-on-fail",
"result": "pass",
"evidence": "python_pkg/app_icons/generate.py: 100% line, 100% branch"
},
{
"command": "PYTHONPATH=~/testsAndMisc python3 -m python_pkg.app_icons generate --android; grep adaptive_icon_background across all 6 pubspec.yaml",
"result": "pass",
"evidence": "All 6 now read #211D1B; diet-guard rebuilt + reinstalled on physical device, home-screen icon background pixel-sampled at (33,29,27) = #211D1B"
}
],
"risks": [
"The regex-based line rewrite assumes flutter_launcher_icons' pubspec.yaml block keeps adaptive_icon_background on its own line in `key: \"#RRGGBB\"` form -- if that config format ever changes, the sync silently becomes a no-op rather than erroring (the function returns False for 'already matches' and 'pattern didn't match' identically). A follow-up could distinguish those two cases if this recurs."
],
"rollback": [
"git revert this commit in testsAndMisc",
"Each app repo's own pubspec.yaml/icon-asset commit can be reverted independently"
]
}

View File

@ -1,39 +0,0 @@
{
"intent": "Warm-tint the shared app_icons family (charcoal field + accent) to match the unified-design-system palette rework, and fix the stale hex/prose left over from the accent-unification pass.",
"scope": [
"python_pkg/app_icons/style.py",
"python_pkg/app_icons/apps.py",
"python_pkg/app_icons/tests/test_registry.py",
"python_pkg/app_icons/README.md"
],
"changes": [
"style.py: BACKGROUND charcoal #1B1D21 -> #211D1B (byte-reversed mirror, same relative lightness)",
"apps.py: all 6 apps' accent #4C7DF0 -> #B8862E; docstring hex updated to match",
"test_registry.py: test_accents_are_shared assertion updated to the new accent",
"README.md: stale charcoal hex and 'own theme accent' wording (already false before this change) corrected"
],
"verification": [
{
"command": "python3 -m pytest python_pkg/app_icons/tests/ -q --no-cov",
"result": "pass",
"evidence": "39 passed"
},
{
"command": "PYTHONPATH=~/testsAndMisc python3 -m python_pkg.app_icons preview -o ...",
"result": "pass",
"evidence": "Visually reviewed contact sheet: all 6 icons render coherently with warm charcoal + warm gold"
},
{
"command": "PYTHONPATH=~/testsAndMisc python3 -m python_pkg.app_icons generate --android",
"result": "pass",
"evidence": "Wrote assets + regenerated Android mipmaps for all 6 consuming repos; diet-guard's rebuilt APK pixel-verified on a physical device"
}
],
"risks": [
"5 of 6 consuming apps (all but diet-guard) had their icon source assets regenerated but their installed APKs were not rebuilt this session, so phone launcher icons for those apps remain stale until each is rebuilt/reinstalled separately"
],
"rollback": [
"git revert this commit in testsAndMisc; each consuming repo's own icon-asset commit can be reverted independently since the generator only writes files, it doesn't couple repos together",
"After rollback, re-run 'python -m python_pkg.app_icons generate --android' to restore the old cool-palette assets everywhere"
]
}

View File

@ -1,8 +1,8 @@
# app_icons — shared launcher icons for the Flutter apps
One icon family across every Flutter/Dart app: a charcoal `#211D1B` field with
a single glyph in the shared `unified-design-system` accent (`#B8862E`),
drawn at one stroke weight and optically centred so a row of them lines up.
One icon family across every Flutter/Dart app: a charcoal `#1B1D21` field with
a single glyph in that app's own theme accent, drawn at one stroke weight and
optically centred so a row of them lines up.
## Commands

View File

@ -1,10 +1,9 @@
"""Registry of the Flutter apps that use the shared icon family.
Adding a new app here (plus a glyph in :mod:`python_pkg.app_icons.glyphs`) is
all that is needed for it to get an on-style icon. The accent is the one
shared family accent (`#B8862E`, from the `unified-design-system` skill) —
apps are distinguished by glyph shape, not color; do not give a new app its
own accent.
all that is needed for it to get an on-style icon. The accent is deliberately
taken from each app's own theme seed so the launcher icon matches the app's
first screen.
"""
from __future__ import annotations
@ -21,8 +20,7 @@ class AppIcon:
Parameters:
key (str): Short identifier used on the command line.
repo (Path): Flutter project root, i.e. the directory holding pubspec.yaml.
accent (str): Hex accent colour. Shared across every app in the family
(the `unified-design-system` accent) — not app-specific.
accent (str): Hex accent colour, matching the app's theme seed.
glyph (str): Glyph name from :data:`~python_pkg.app_icons.glyphs.GLYPHS`.
icon_name (str): Basename for Linux hicolor/desktop installation.
linux (bool): Whether the app has a Linux desktop target.
@ -52,7 +50,7 @@ APPS: Final[dict[str, AppIcon]] = {
# was superseded when dufs-cloud absorbed it (see testsAndMisc
# CLAUDE.md). Same package name, so it is easy to icon the wrong one.
repo=_HOME / "dufs-cloud" / "app",
accent="#B8862E",
accent="#5C6BC0",
glyph="cloud-down",
icon_name="dufs-client",
linux=False,
@ -60,7 +58,7 @@ APPS: Final[dict[str, AppIcon]] = {
AppIcon(
key="workout_app",
repo=_HOME / "screen-locker" / "stronglift_replacement" / "workout_app",
accent="#B8862E",
accent="#FF4444",
glyph="barbell",
icon_name="workout-app",
linux=False,
@ -68,7 +66,7 @@ APPS: Final[dict[str, AppIcon]] = {
AppIcon(
key="wake_alarm_sync",
repo=_HOME / "wake-alarm" / "phone_app",
accent="#B8862E",
accent="#FFA726",
glyph="clock",
icon_name="wake-alarm-sync",
linux=False,
@ -76,7 +74,7 @@ APPS: Final[dict[str, AppIcon]] = {
AppIcon(
key="diet_guard_app",
repo=_HOME / "diet-guard" / "app",
accent="#B8862E",
accent="#26A69A",
glyph="shield-cutlery",
icon_name="diet-guard-app",
linux=True,
@ -84,7 +82,7 @@ APPS: Final[dict[str, AppIcon]] = {
AppIcon(
key="todo",
repo=_HOME / "todo",
accent="#B8862E",
accent="#7E57C2",
glyph="checklist",
icon_name="todo",
linux=True,
@ -92,7 +90,7 @@ APPS: Final[dict[str, AppIcon]] = {
AppIcon(
key="habit_stack",
repo=_HOME / "habit_stack",
accent="#B8862E",
accent="#66BB6A",
glyph="chain-link",
icon_name="habit-stack",
linux=False,

View File

@ -17,19 +17,11 @@ needs rsvg-convert installed.
from __future__ import annotations
import re
import subprocess
from typing import TYPE_CHECKING, Final
from python_pkg.app_icons import glyphs, render, style
# Matches a `flutter_launcher_icons:` block's `adaptive_icon_background:` line
# so it can be kept in sync with style.BACKGROUND without a full YAML
# round-trip (which would reformat the rest of the file).
_ADAPTIVE_BG_RE: Final[re.Pattern[str]] = re.compile(
r'^(\s*adaptive_icon_background:\s*)"#[0-9A-Fa-f]{6}"(\s*)$', re.MULTILINE
)
if TYPE_CHECKING:
from pathlib import Path
@ -92,44 +84,16 @@ def write_linux_icons(app: AppIcon, destination: Path) -> list[Path]:
return written
def sync_pubspec_background(app: AppIcon) -> bool:
"""Rewrite pubspec.yaml's ``adaptive_icon_background`` to match style.BACKGROUND.
flutter_launcher_icons reads the adaptive-icon background color from
pubspec.yaml, not from this package -- a value that has to be kept in
sync by hand has drifted before (six apps kept `#1B1D21` in pubspec.yaml
after style.BACKGROUND moved to `#211D1B`, so the on-device icon stayed
on the old color even though every generated asset was correct). This
makes that class of drift impossible instead of relying on remembering
to update it.
Parameters:
app (AppIcon): App whose pubspec.yaml should be synced.
Returns:
bool: True if the file was changed, False if it already matched.
"""
pubspec_path = app.repo / "pubspec.yaml"
original = pubspec_path.read_text(encoding="utf-8")
updated = _ADAPTIVE_BG_RE.sub(rf'\1"{style.BACKGROUND}"\2', original, count=1)
if updated == original:
return False
pubspec_path.write_text(updated, encoding="utf-8")
return True
def run_flutter_launcher_icons(app: AppIcon) -> None:
"""Generate the Android mipmap set from the written assets.
flutter_launcher_icons owns the error-prone part: five density buckets, the
round variant, and the ``mipmap-anydpi-v26/ic_launcher.xml`` adaptive
descriptor that none of these repos had before. Syncs pubspec.yaml's
adaptive_icon_background first so the tool never reads a stale value.
descriptor that none of these repos had before.
Parameters:
app (AppIcon): App whose Flutter project should be processed.
"""
sync_pubspec_background(app)
subprocess.run(
[render.resolve_tool("dart"), "run", "flutter_launcher_icons"],
cwd=app.repo,

View File

@ -14,10 +14,8 @@ CANVAS: Final[int] = 1024
CENTRE: Final[float] = CANVAS / 2
# Charcoal field shared by all icons. Also used as adaptive_icon_background so
# the adaptive foreground and background layers stay seamless. Warm-tinted
# (unified-design-system `ink`) — a byte-reversed mirror of the previous
# cool-tinted #1B1D21, so relative lightness is unchanged.
BACKGROUND: Final[str] = "#211D1B"
# the adaptive foreground and background layers stay seamless.
BACKGROUND: Final[str] = "#1B1D21"
# Android masks an adaptive icon down to roughly the inner 66% of the canvas.
# Keeping every glyph inside this box means no launcher mask (circle, squircle,

View File

@ -73,47 +73,6 @@ class TestWriteLinuxIcons:
assert written[0] == tmp_path / "h" / "16" / "demo.png"
def _write_pubspec(app: AppIcon, *, background: str = "#1B1D21") -> Path:
app.repo.mkdir(parents=True, exist_ok=True)
pubspec = app.repo / "pubspec.yaml"
pubspec.write_text(
"flutter_launcher_icons:\n"
' image_path: "assets/icon/icon.png"\n'
f' adaptive_icon_background: "{background}"\n'
' adaptive_icon_foreground: "assets/icon/icon_foreground.png"\n',
encoding="utf-8",
)
return pubspec
class TestSyncPubspecBackground:
def test_rewrites_a_stale_background(self, tmp_path: Path) -> None:
app = _app(tmp_path)
pubspec = _write_pubspec(app, background="#1B1D21")
changed = generate.sync_pubspec_background(app)
assert changed is True
assert f'adaptive_icon_background: "{style.BACKGROUND}"' in pubspec.read_text(
encoding="utf-8"
)
def test_leaves_other_lines_untouched(self, tmp_path: Path) -> None:
app = _app(tmp_path)
pubspec = _write_pubspec(app, background="#1B1D21")
before = pubspec.read_text(encoding="utf-8")
generate.sync_pubspec_background(app)
after = pubspec.read_text(encoding="utf-8")
assert before.splitlines()[0] == after.splitlines()[0]
assert 'adaptive_icon_foreground: "assets/icon/icon_foreground.png"' in after
def test_no_op_when_already_current(self, tmp_path: Path) -> None:
app = _app(tmp_path)
pubspec = _write_pubspec(app, background=style.BACKGROUND)
before_mtime = pubspec.stat().st_mtime_ns
changed = generate.sync_pubspec_background(app)
assert changed is False
assert pubspec.stat().st_mtime_ns == before_mtime
class TestRunFlutterLauncherIcons:
@patch(f"{MOD}.subprocess.run")
@patch(f"{MOD}.render.resolve_tool", return_value="/usr/bin/dart")
@ -121,7 +80,6 @@ class TestRunFlutterLauncherIcons:
self, mock_tool: MagicMock, run: MagicMock, tmp_path: Path
) -> None:
app = _app(tmp_path)
_write_pubspec(app)
generate.run_flutter_launcher_icons(app)
assert run.call_args.args[0] == [
"/usr/bin/dart",
@ -129,15 +87,3 @@ class TestRunFlutterLauncherIcons:
"flutter_launcher_icons",
]
assert run.call_args.kwargs["cwd"] == app.repo
@patch(f"{MOD}.subprocess.run")
@patch(f"{MOD}.render.resolve_tool", return_value="/usr/bin/dart")
def test_syncs_pubspec_background_before_invoking_dart(
self, mock_tool: MagicMock, run: MagicMock, tmp_path: Path
) -> None:
app = _app(tmp_path)
pubspec = _write_pubspec(app, background="#1B1D21")
generate.run_flutter_launcher_icons(app)
assert f'adaptive_icon_background: "{style.BACKGROUND}"' in pubspec.read_text(
encoding="utf-8"
)

View File

@ -34,10 +34,9 @@ class TestFamilyInvariants:
for app in apps.APPS.values():
assert app.glyph in glyphs.GLYPHS
def test_accents_are_shared(self) -> None:
"""Every app uses the one family accent; apps differ by glyph only."""
accents = {app.accent for app in apps.APPS.values()}
assert accents == {"#B8862E"}
def test_accents_are_unique(self) -> None:
accents = [app.accent for app in apps.APPS.values()]
assert len(set(accents)) == len(accents)
def test_accents_are_hex_triplets(self) -> None:
for app in apps.APPS.values():