Give catalog apps their icons and share Android controller assets

This commit is contained in:
waozi committed 2026-10-22 16:56:48 -03:00
1 parent 4ddd4fb5c0
commit 6a2121b2d7
21 files changed
+198 -53

No files matched your search

+1
View File
@@ -4,6 +4,7 @@
- Keep practice animation smooth in the browser.
- Restore clean F-Droid builds.
- Show distinct Photos, Radio and Library icons in Apps, including before installation.
## [2.1.41] - 2026-10-22
+1
View File
@@ -396,6 +396,7 @@ CELL_SOURCES := $(shell find apps src/cells -name '*.zi' | LC_ALL=C sort) src/co
CELL_RESOURCES := $(shell rg --files assets/habits assets/lists assets/diary assets/lumi assets/mcp 2>/dev/null)
CELL_RESOURCES += $(shell rg --files assets/practices design/tai-chi/text 2>/dev/null) apps/practice/content.json design/tai-chi/narration.json design/tai-chi/narration-lines.json $(wildcard design/tai-chi/narration-receipt.json) $(wildcard design/sun-salutation/narration/*.json) $(wildcard design/sun-salutation/narration/text/*.txt) $(wildcard design/lumi-guide/*.json) scripts/practice_content.py scripts/generate-lumi-guide-narration.py
CELL_RESOURCES += $(wildcard apps/*/achievements.json) $(wildcard apps/*/achievement-locales/*.json)
CELL_RESOURCES += $(wildcard assets/*/sidebar.shape)
# Read here, before TARGET is set: its UI tests do not build $(TARGET) first.
include mk/tests-lumi.mk
+4
View File
@@ -1,5 +1,9 @@
# Radio
## [1.0.2] - 2026-10-22
- Give Radio its own icon in Apps and the sidebar.
## [1.0.1] - 2026-10-21
- Give each achievement its own meaningful icon.
+2 -2
View File
@@ -78,8 +78,8 @@
"radio": {
"id": "inbe.radio",
"title": "Radio",
"version": "1.0.1",
"sequence": 2,
"version": "1.0.2",
"sequence": 3,
"host_api": 18
}
}
+1
View File
@@ -0,0 +1 @@
S2rr:M7 13H8M7 16H10M8.5 4L19.5 8M17 14C17 15.1046 16.1046 16 15 16C13.8954 16 13 15.1046 13 14C13 12.8954 13.8954 12 15 12C16.1046 12 17 12.8954 17 14ZM4 20H20C20.5523 20 21 19.5523 21 19V9C21 8.44772 20.5523 8 20 8H4C3.44772 8 3 8.44772 3 9V19C3 19.5523 3.44772 20 4 20Z
+5
View File
@@ -39,6 +39,11 @@ A clean Gradle build also needs the shared Apps controller before native
compilation. Android's CMake tasks now depend on package preparation, so the
F-Droid build cannot accidentally rely on a bundle left by a desktop build.
The reviewed Apps controller now lives once in APK assets, beside the main
app package, rather than being embedded in every CPU library. The Android
asset reader retains each package independently across Activity replacement.
Archive checks require both shared packages and keep the native size budgets.
The upstream F-Droid entry must use the full commit of a successfully
published release and its corresponding `inbe-VERSION-fdroid.apk` binary.
A passing GitHub check does not mean F-Droid has merged or distributed that
+3 -2
View File
@@ -187,14 +187,15 @@ def sharedAppAssets = layout.buildDirectory.dir('generated/app-assets')
def stageAppPackage = tasks.register('stageAppPackage', Sync) {
dependsOn 'prepareAppPackage'
from(rootProject.file('../build/inbe.zib'))
from(rootProject.file('../build/apps-ui/apps.zib'))
into(sharedAppAssets)
}
// Declare generated sources through their producing task; lint consumers also
// need the explicit dependency below because AGP resolves their paths eagerly.
android.sourceSets.main.assets.srcDir(stageAppPackage)
tasks.configureEach { task ->
// Native bootstrap assets include the shared Apps controller. A clean
// Gradle/F-Droid build must produce it before Ninja reads its inputs.
// A clean Gradle/F-Droid build must produce the shared packages before
// configuring the native host and staging APK assets.
if (task.name.startsWith('configureCMake') || task.name.startsWith('buildCMake')) {
task.dependsOn('prepareAppPackage')
}
-1
View File
@@ -228,7 +228,6 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
"${REPO_ROOT}/scripts/build-bundle-runtime.py" "${REPO_ROOT}/ziran.lock")
set(APP_EMBEDDED_INPUTS
build/apps-ui/apps.zib
apps/publishers.json
assets/app/icon.png
)
@@ -1,2 +1,3 @@
- Keep practice animation smooth in the browser.
- Restore clean F-Droid builds.
- Show distinct Photos, Radio and Library icons in Apps, including before installation.
+3
View File
@@ -28,6 +28,9 @@ def check(path, budgets):
raise ValueError("Expected exactly one shared assets/inbe.zib")
package = packages[0]
within("Portable app package", package.file_size, budgets["app_package_bytes"])
controllers = [entry for entry in files if entry.filename.endswith("/apps.zib")]
if len(controllers) != 1 or controllers[0].filename != prefix + "assets/apps.zib":
raise ValueError("Expected exactly one shared assets/apps.zib controller")
libraries = [entry for entry in files
if entry.filename.startswith(prefix + "lib/")
and entry.filename.endswith("/libmain.so")]
+9
View File
@@ -91,6 +91,15 @@ for file in sorted({p for pattern in patterns for p in ROOT.glob(pattern) if p.i
continue
shutil.copyfile(file, target)
# Catalog outlines are small metadata, available before an app is installed.
# The app retains its own copy for standalone and embedded use.
for name in NODE_APPS:
source = ROOT / 'assets' / name / 'sidebar.shape'
if source.is_file():
destination = OUTPUT / 'inbe/assets/apps/icons' / (name + '.shape')
destination.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(source, destination)
# Root launcher cards share the reviewed Apps controller. A node-only build
# can omit it; the root bundle build below requires this asset explicitly.
apps_bundle = ROOT / 'build/apps-ui/apps.zib'
+2 -1
View File
@@ -251,7 +251,8 @@ export async function verifySunSalutationCanvas({ evaluate, click, resize, captu
probe.meshSources.set(source, !!source.getContext('webgl'));
if (probe.meshSources.get(source)) {
probe.meshTransfers++;
probe.meshPixels += source.width * source.height;
probe.meshPixels += args.length === 9
? args[3] * args[4] : source.width * source.height;
if (${process.env.WEB_SMOKE_MESH_TRACE === '1'} && probe.meshStacks.length < 2) {
Error.stackTraceLimit = 40;
probe.meshStacks.push(new Error('mesh transfer').stack);
+1 -1
View File
@@ -522,7 +522,7 @@ app_draw_launcher :: (app: *InnerBreeze, dock_drawn: bool) {
preview.icon_shape = app_nav_route_shape(app.launcher_drag_route)
} else {
preview.label = NodeAppTitle(LauncherLibraryName(app.launcher_drag_route))
preview.icon_shape = NODE_APP_GENERIC_ICON
preview.icon_shape = NodeAppCatalogIcon(LauncherLibraryName(app.launcher_drag_route))
}
preview.bounds = app.launcher_drag_bounds
preview.bounds.x = point.x - app.launcher_drag_grab.x
+1 -1
View File
@@ -362,7 +362,7 @@ LauncherAppCatalogEntry :: (group: *LauncherAppGroup, bytes: *Vec(u8), route: s3
unused CopyCString(id, entry.id[:])
PackageFree(id)
title = NodeAppTitle(name)
shape = NODE_APP_GENERIC_ICON
shape = NodeAppCatalogIcon(name)
size = NodeAppOfferSize(offer)
}
if group.count > 0 { BuilderPrint(bytes, ",") }
+2 -2
View File
@@ -104,8 +104,8 @@ AssetViewFor :: (path: string) -> AssetView {
if supplied.found { return supplied }
}
#if #defined(ANDROID_BUILD) {
if path == "inbe.zib" {
package := AndroidPackageBytes()
if path == "inbe.zib" || path == "apps.zib" {
package := AndroidPackageBytes(path)
if package.count > 0 {
return .{.data = package, .mime = "application/octet-stream", .found = true}
}
+20 -5
View File
@@ -294,8 +294,21 @@ NodeAppIconValid :: (shape: string) -> bool {
return shape.count > 6 && shape.count < NODE_APP_ICON_MAX && shape[:1] == "S"
}
// The app's outline icon from its package, or a plain grid while none is
// installed.
// Small catalog icons remain available before the app is downloaded.
NodeAppCatalogIcon :: (name: string) -> string {
if !NodeAppNameValid(name) { return NODE_APP_GENERIC_ICON }
prefix := PackageText("assets/apps/icons/", name)
path := PackageText(prefix, ".shape")
defer {
PackageFree(prefix)
PackageFree(path)
}
asset := AssetRead(path)
if asset.found && NodeAppIconValid(asset.data) { return asset.data }
return NODE_APP_GENERIC_ICON
}
// Prefer an installed app's own outline, then its catalog icon.
NodeAppIconShape :: (slot: s32) -> string {
if NodeAppRunning(slot) {
path := NodeAppAssetPath(NodeAppName(slot), "sidebar.shape")
@@ -307,18 +320,20 @@ NodeAppIconShape :: (slot: s32) -> string {
return asset.data
}
}
if slot < 0 || slot >= NodeAppSlots || !NodeAppInstalled(slot) {
if slot < 0 || slot >= NodeAppSlots {
return NODE_APP_GENERIC_ICON
}
fallback := NodeAppCatalogIcon(NodeAppName(slot))
if !NodeAppInstalled(slot) { return fallback }
version := ifx NodeAppLocal(NodeAppName(slot)) then "local" else PackageVersion(NodeAppIndex(slot))
if version.count == 0 || version.count >= NODE_APP_ICON_VERSION_MAX {
return NODE_APP_GENERIC_ICON
return fallback
}
if TextUntilNul(node_icon_versions[slot][:]) != version {
NodeAppLoadIcon(slot, version)
}
if node_icon_sizes[slot] == 0 {
return NODE_APP_GENERIC_ICON
return fallback
}
return TextFromBytes(node_icons[slot][:node_icon_sizes[slot]])
}
+25 -12
View File
@@ -1,5 +1,5 @@
// The portable app package is shared by every ABI in the APK. Keep the NDK
// asset open for the lifetime of its borrowed bytes, including Activity resets.
// Portable packages are shared by every ABI in the APK. Keep each NDK asset
// open for the lifetime of its borrowed bytes, including Activity resets.
#import "android_jni"
#import "byte_text_linux"
@@ -12,21 +12,34 @@
PackageAssetBuffer :: (asset: *void) -> *u8 #foreign android "AAsset_getBuffer";
PackageAssetLength :: (asset: *void) -> s64 #foreign android "AAsset_getLength64";
PackageAssetClose :: (asset: *void) #foreign android "AAsset_close";
package_asset: *void;
package_bytes: string;
PackageAsset :: struct {
asset: *void
bytes: string
}
package_assets: [2]PackageAsset;
}
AndroidPackageBytes :: () -> string {
AndroidPackageBytes :: (path: string) -> string {
#if #defined(ANDROID_BUILD) {
if package_asset != null {
return package_bytes
index: s32 = 0
if path == "apps.zib" {
index = 1
} else if path != "inbe.zib" {
return ""
}
cached := *package_assets[index]
if cached.asset != null {
return cached.bytes
}
app := PackageAndroidApp()
if app == null || app.activity == null || app.activity.asset_manager == null {
return ""
}
path: [9]u8 = .[105, 110, 98, 101, 46, 122, 105, 98, 0]
asset := PackageAssetOpen(app.activity.asset_manager, *path[0], 3)
name: [9]u8
for offset: cast(s32)0..7 {
name[offset] = path[offset]
}
asset := PackageAssetOpen(app.activity.asset_manager, *name[0], 3)
if asset == null {
return ""
}
@@ -36,9 +49,9 @@ AndroidPackageBytes :: () -> string {
PackageAssetClose(asset)
return ""
}
package_asset = asset
package_bytes = TextFromBytes(BytesFromPointer(data, cast(u64)length))
return package_bytes
cached.asset = asset
cached.bytes = TextFromBytes(BytesFromPointer(data, cast(u64)length))
return cached.bytes
}
return ""
}
+14
View File
@@ -13,6 +13,20 @@ PackageSize :: () -> s64 {
return view.data.count
}
#program_export
AppsPackageSize :: () -> s64 {
view := AssetRead("apps.zib")
if !view.found {
return 0
}
if view.mime != "application/octet-stream" || view.data.count != 9 ||
view.data[0] != 90 || view.data[1] != 73 || view.data[2] != 66 ||
view.data[8] != 65 {
return -1
}
return view.data.count
}
#program_export
MissingPackageAsset :: () -> bool {
return !AssetRead("missing.zib").found
+81 -24
View File
@@ -6,9 +6,21 @@
static NativeActivity activity;
static NativeAndroidApp app;
static int available, fail_open, fail_buffer, opens, closes;
static int64_t length;
static uint8_t bytes[] = {'Z', 'I', 'B', 0, 26, 0, 0, 0};
static int available;
static uint8_t package_bytes[] = {'Z', 'I', 'B', 0, 26, 0, 0, 0};
static uint8_t apps_bytes[] = {'Z', 'I', 'B', 0, 26, 0, 0, 0, 'A'};
typedef struct {
int fail_open;
int fail_buffer;
int opens;
int closes;
int64_t length;
uint8_t *bytes;
} TestAsset;
static TestAsset package_asset = {.bytes = package_bytes};
static TestAsset apps_asset = {.bytes = apps_bytes};
NativeAndroidApp *GetAndroidApp(void) { return available ? &app : NULL; }
size_t asset_entry_total(void) { return 0; }
@@ -16,40 +28,85 @@ const AssetEntry *asset_entry_at(size_t index) { (void)index; return NULL; }
void *AAssetManager_open(void *manager, uint8_t *path, int32_t mode)
{
assert(manager == &activity && strcmp((char *)path, "inbe.zib") == 0);
assert(manager == &activity);
assert(mode == 3);
opens++;
return fail_open ? NULL : &app;
TestAsset *asset;
if (strcmp((char *)path, "inbe.zib") == 0) {
asset = &package_asset;
} else {
assert(strcmp((char *)path, "apps.zib") == 0);
asset = &apps_asset;
}
asset->opens++;
return asset->fail_open ? NULL : asset;
}
int64_t AAsset_getLength64(void *asset) { assert(asset == &app); return length; }
uint8_t *AAsset_getBuffer(void *asset)
int64_t AAsset_getLength64(void *handle)
{
assert(asset == &app);
return fail_buffer ? NULL : bytes;
TestAsset *asset = handle;
assert(asset == &package_asset || asset == &apps_asset);
return asset->length;
}
uint8_t *AAsset_getBuffer(void *handle)
{
TestAsset *asset = handle;
assert(asset == &package_asset || asset == &apps_asset);
return asset->fail_buffer ? NULL : asset->bytes;
}
void AAsset_close(void *handle)
{
TestAsset *asset = handle;
assert(asset == &package_asset || asset == &apps_asset);
asset->closes++;
}
void AAsset_close(void *asset) { assert(asset == &app); closes++; }
int main(void)
{
assert(PackageSize() == 0);
assert(AppsPackageSize() == 0);
available = 1;
assert(PackageSize() == 0);
assert(AppsPackageSize() == 0);
app.activity = &activity;
assert(PackageSize() == 0 && opens == 0);
assert(PackageSize() == 0 && package_asset.opens == 0);
assert(AppsPackageSize() == 0 && apps_asset.opens == 0);
activity.asset_manager = &activity;
fail_open = 1;
assert(PackageSize() == 0 && opens == 1 && closes == 0);
fail_open = 0;
assert(PackageSize() == 0 && opens == 2 && closes == 1);
length = sizeof(bytes);
fail_buffer = 1;
assert(PackageSize() == 0 && opens == 3 && closes == 2);
fail_buffer = 0;
assert(PackageSize() == sizeof(bytes) && opens == 4 && closes == 2);
/* Retained borrowed bytes survive Activity replacement and repeat reads. */
package_asset.fail_open = 1;
assert(PackageSize() == 0 && package_asset.opens == 1 && package_asset.closes == 0);
package_asset.fail_open = 0;
assert(PackageSize() == 0 && package_asset.opens == 2 && package_asset.closes == 1);
package_asset.length = sizeof(package_bytes);
package_asset.fail_buffer = 1;
assert(PackageSize() == 0 && package_asset.opens == 3 && package_asset.closes == 2);
package_asset.fail_buffer = 0;
assert(PackageSize() == sizeof(package_bytes) && package_asset.opens == 4 && package_asset.closes == 2);
/* Loading one asset must not mark the other asset as loaded. */
available = 0;
app.activity = NULL;
assert(PackageSize() == sizeof(bytes) && opens == 4 && closes == 2);
assert(MissingPackageAsset() && opens == 4);
assert(PackageSize() == sizeof(package_bytes) && package_asset.opens == 4);
assert(AppsPackageSize() == 0 && apps_asset.opens == 0);
available = 1;
app.activity = &activity;
apps_asset.fail_open = 1;
assert(AppsPackageSize() == 0 && apps_asset.opens == 1 && apps_asset.closes == 0);
apps_asset.fail_open = 0;
assert(AppsPackageSize() == 0 && apps_asset.opens == 2 && apps_asset.closes == 1);
apps_asset.length = sizeof(apps_bytes);
apps_asset.fail_buffer = 1;
assert(AppsPackageSize() == 0 && apps_asset.opens == 3 && apps_asset.closes == 2);
apps_asset.fail_buffer = 0;
assert(AppsPackageSize() == sizeof(apps_bytes) && apps_asset.opens == 4 && apps_asset.closes == 2);
assert(PackageSize() == sizeof(package_bytes) && package_asset.opens == 4);
/* Both independent borrowed views survive Activity replacement. */
NativeActivity replacement_activity = {0};
app.activity = &replacement_activity;
assert(PackageSize() == sizeof(package_bytes) && package_asset.opens == 4);
assert(AppsPackageSize() == sizeof(apps_bytes) && apps_asset.opens == 4);
available = 0;
app.activity = NULL;
assert(PackageSize() == sizeof(package_bytes) && package_asset.closes == 2);
assert(AppsPackageSize() == sizeof(apps_bytes) && apps_asset.closes == 2);
assert(MissingPackageAsset() && package_asset.opens == 4 && apps_asset.opens == 4);
return 0;
}
+4
View File
@@ -43,6 +43,10 @@ def assets(data):
return result
root = assets((ROOT / 'build/inbe.zib').read_bytes())
for name in ('photos', 'radio', 'library'):
shape = (ROOT / 'assets' / name / 'sidebar.shape').read_bytes()
assert root['assets/apps/icons/' + name + '.shape'] == shape
assert shape.startswith(b'S') and len(shape) < 4096
assert set(name for name in root if name.startswith('cells/')) == {
'cells/lumi.zib', 'cells/habits.zib', 'cells/practices.zib',
'cells/lists.zib', 'cells/diary.zib', 'cells/leaderboard.zib'}
+18 -2
View File
@@ -26,7 +26,8 @@ class PackageSizeTest(unittest.TestCase):
return MODULE.check(path, budgets)
def test_one_shared_package_for_four_abis(self):
entries = {"assets/inbe.zib": b"portable program and artwork"}
entries = {"assets/inbe.zib": b"portable program and artwork",
"assets/apps.zib": b"reviewed Apps controller"}
for abi in ("arm64-v8a", "armeabi-v7a", "x86", "x86_64"):
entries[f"lib/{abi}/libmain.so"] = b"native platform host"
self.assertIn("4 ABI(s); one shared package", self.check_archive(entries))
@@ -42,20 +43,35 @@ class PackageSizeTest(unittest.TestCase):
def test_native_asset_bloat_fails(self):
with self.assertRaisesRegex(ValueError, "libmain.so"):
self.check_archive({"assets/inbe.zib": b"package",
"assets/apps.zib": b"controller",
"lib/arm64-v8a/libmain.so": b"image" * 100},
native_library_bytes=100)
def test_bundle_checks_delivered_payload_without_crash_symbols(self):
self.assertIn("one shared package", self.check_archive({
"base/assets/inbe.zib": b"package", "base/lib/arm64-v8a/libmain.so": b"host",
"base/assets/inbe.zib": b"package", "base/assets/apps.zib": b"controller",
"base/lib/arm64-v8a/libmain.so": b"host",
"BUNDLE-METADATA/com.android.tools.build.debugsymbols/symbols": b"symbol" * 10000,
}, suffix=".aab", bundle_payload_bytes=100))
def test_total_apk_budget_fails(self):
with self.assertRaisesRegex(ValueError, "APK"):
self.check_archive({"assets/inbe.zib": b"package",
"assets/apps.zib": b"controller",
"lib/arm64-v8a/libmain.so": b"host"}, apk_single_abi_bytes=10)
def test_missing_shared_controller_fails(self):
with self.assertRaisesRegex(ValueError, "exactly one shared assets/apps.zib"):
self.check_archive({"assets/inbe.zib": b"package",
"lib/arm64-v8a/libmain.so": b"host"})
def test_duplicate_controller_fails(self):
with self.assertRaisesRegex(ValueError, "exactly one shared assets/apps.zib"):
self.check_archive({"assets/inbe.zib": b"package",
"assets/apps.zib": b"controller",
"assets/copy/apps.zib": b"controller",
"lib/arm64-v8a/libmain.so": b"host"})
if __name__ == "__main__":
unittest.main()