diff --git a/packaging/ohos/README.md b/packaging/ohos/README.md new file mode 100644 index 000000000..6826aa958 --- /dev/null +++ b/packaging/ohos/README.md @@ -0,0 +1,51 @@ +# HarmonyOS (OpenHarmony) app icon + +Robrix's branded launcher icon for the HarmonyOS build lives here, plus a script +that applies it to the generated DevEco project. + +## Why this exists + +`cargo makepad ohos ... deveco` scaffolds the DevEco project from cargo-makepad's +built-in template. That template ships **makepad's placeholder icon**, and the ohos +generator has **no hook to use the project's real icon** (the Android path does — +it reads `[package.metadata.makepad.android].icons` in `Cargo.toml`). The project is +also regenerated under `target/` on every `deveco` run, so the icon cannot simply be +committed into the generated tree. + +So without this step, Robrix shows the generic makepad icon on the HarmonyOS launcher +instead of the Robrix logo. + +## Files + +| File | Used by | Notes | +|------|---------|-------| +| `media/foreground.png` | `$media:foreground` (layered launcher icon) | 288×288, transparent cube in the Ø192 safe zone | +| `media/background.png` | `$media:background` (layered launcher icon) | 288×288, solid white | +| `media/app_icon.png` | `AppScope/app.json5` → `$media:app_icon` | 216×216, cube on white | +| `media/startIcon.png` | `EntryAbility` → `$media:startIcon` | 288×288, cube on white | + +The launcher icon follows HarmonyOS's **layered icon** convention: a transparent +foreground (the Robrix cube, kept inside the Ø192 safe area) over a solid background, +with the system supplying the mask and elevation — no baked-in card/shadow. The cube +artwork is derived from `resources/robrix_logo_alpha.png`. + +## Build flow + +Run the icon step between `deveco` and `build`: + +```bash +# 1. generate the DevEco project + cross-compile librobrix.so +cargo makepad ohos --deveco-home="/Applications/DevEco-Studio.app/Contents" deveco -p robrix --release + +# 2. inject Robrix's icon (this script) — must come after deveco, before build +packaging/ohos/apply-app-icon.sh + +# 3. package the .hap +cargo makepad ohos --deveco-home="/Applications/DevEco-Studio.app/Contents" build -p robrix --release +``` + +## Follow-up + +The proper long-term fix is upstream: teach cargo-makepad's ohos generator to read the +project's icon (as the Android path already does) and generate the layered icon, which +would make this script unnecessary. diff --git a/packaging/ohos/apply-app-icon.sh b/packaging/ohos/apply-app-icon.sh new file mode 100755 index 000000000..6842a4e15 --- /dev/null +++ b/packaging/ohos/apply-app-icon.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# apply-app-icon.sh — inject Robrix's branded launcher icon into the generated +# OpenHarmony (HarmonyOS) DevEco project. +# +# Why this is needed: +# `cargo makepad ohos ... deveco` scaffolds the DevEco project from cargo-makepad's +# own template, which ships makepad's placeholder icon and has no hook to use the +# project's real icon (unlike the Android path, which reads +# [package.metadata.makepad.android].icons in Cargo.toml). It also regenerates the +# project under target/ on every run, so the icon cannot simply be committed there. +# This script copies Robrix's icons (packaging/ohos/media/) into the freshly +# generated project. +# +# When to run: AFTER `cargo makepad ohos ... deveco`, BEFORE `... build`. +# +# usage: packaging/ohos/apply-app-icon.sh [deveco_project_dir] +# deveco_project_dir defaults to target/makepad-open-harmony/robrix +set -euo pipefail + +HERE="$(cd "$(dirname "$0")" && pwd)" +MEDIA="$HERE/media" +PROJ="${1:-target/makepad-open-harmony/robrix}" + +[ -d "$PROJ" ] || { + echo "error: DevEco project not found at '$PROJ'" >&2 + echo " run 'cargo makepad ohos ... deveco -p robrix' first." >&2 + exit 1 +} + +APPSCOPE_MEDIA="$PROJ/AppScope/resources/base/media" +ENTRY_MEDIA="$PROJ/entry/src/main/resources/base/media" +[ -d "$APPSCOPE_MEDIA" ] && [ -d "$ENTRY_MEDIA" ] || { + echo "error: '$PROJ' does not look like a makepad DevEco project (missing media dirs)" >&2 + exit 1 +} + +# app-level icon (AppScope/app.json5 -> $media:app_icon) +cp "$MEDIA/app_icon.png" "$APPSCOPE_MEDIA/app_icon.png" +# launcher layered icon (media/layered_image.json -> $media:foreground over $media:background) +cp "$MEDIA/foreground.png" "$ENTRY_MEDIA/foreground.png" +cp "$MEDIA/background.png" "$ENTRY_MEDIA/background.png" +# start-window icon (module.json5 EntryAbility -> $media:startIcon) +cp "$MEDIA/startIcon.png" "$ENTRY_MEDIA/startIcon.png" + +echo "Robrix app icon applied to $PROJ" diff --git a/packaging/ohos/media/app_icon.png b/packaging/ohos/media/app_icon.png new file mode 100644 index 000000000..9db2aa029 Binary files /dev/null and b/packaging/ohos/media/app_icon.png differ diff --git a/packaging/ohos/media/background.png b/packaging/ohos/media/background.png new file mode 100644 index 000000000..87216ab85 Binary files /dev/null and b/packaging/ohos/media/background.png differ diff --git a/packaging/ohos/media/foreground.png b/packaging/ohos/media/foreground.png new file mode 100644 index 000000000..87009f017 Binary files /dev/null and b/packaging/ohos/media/foreground.png differ diff --git a/packaging/ohos/media/startIcon.png b/packaging/ohos/media/startIcon.png new file mode 100644 index 000000000..7e441b686 Binary files /dev/null and b/packaging/ohos/media/startIcon.png differ