Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions packaging/ohos/README.md
Original file line number Diff line number Diff line change
@@ -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.
45 changes: 45 additions & 0 deletions packaging/ohos/apply-app-icon.sh
Original file line number Diff line number Diff line change
@@ -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"
Binary file added packaging/ohos/media/app_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packaging/ohos/media/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packaging/ohos/media/foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packaging/ohos/media/startIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading