NextGram/plugins Build a plugin Resources

Resource overrides

Fonts, sounds, wallpaper, icons, strings, haptics, motion and chrome overrides.

ResourcesHost owns fonts, notification and in-app sounds, the outgoing ringtone, reaction sounds, wallpaper, icon packs, allowlisted strings, haptics, motion and status/navigation bar chrome. AppearanceHost keeps colors, blur and avatar shape.

1. One atomic provider#

java
ResourcesHost resources = context.require(ResourcesHost.class);
resources.apply(AppResources.builder()
        .font(FontRole.REGULAR, "assets/fonts/regular.ttf")
        .font(FontRole.BOLD, "assets/fonts/bold.ttf")
        .sound(SoundRole.NOTIFICATION, "assets/sounds/notify.ogg")
        .wallpaper(WallpaperSpec.asset("assets/wallpaper.webp").withBlur(0.2f))
        .string("settings.title", "Settings")
        .build());

Validation is all-or-nothing. A single invalid asset or key fails the whole set with E_RESOURCE_INVALID and applies nothing. After validation, a runtime load failure falls back per role to the next provider down the stack, then to stock.

Providers form a stack ordered by successful apply time. A plugin occupies exactly one entry; a second successful apply updates it and moves it to the top with a new monotonic sequence number. A late completion with an older sequence number is discarded. Disabling or uninstalling a provider removes its entry and restores the next provider or stock, without a restart.

Only one resource provider is active. The manager shows its name and a kernel-owned Reset resources action that clears the whole stack. Safe mode resets resources.

2. Limits#

ResourceRules
FontTTF/OTF, 8 MB each, max 8 files; roles regular/medium/bold/italic/mono/code; sfnt/OTTO/true/ttcf magic
SoundOGG/MP3/WAV, 5 MB each, max 16 files, max 60 s; roles notification/inAppSent/inAppReceived/reaction/ringtone
WallpaperPNG/WebP, 10 MB, max 4096x4096; asset, gradient (2–8 colors) or solid; optional blur/dim
IconPNG/WebP, 1 MB, 512x512, max 128; keys from the host icon catalogue
StringPlain text, max 2,000 chars, max 200; allowlisted non-security keys only
Haptic1–8 steps, max 2 s total, max 16 roles
MotionDuration 0–5,000 ms, max 16 entries
Total copied assets32 MB per plugin

Assets are copied from the package into the plugin cache and made read-only. The host never loads an asset directly from the package.

3. Fonts#

Fonts are applied through a host resolver seam; text that cached a Typeface refreshes on the next screen creation. Per-role fallback is deterministic. WOFF/WOFF2 are rejected because Android Typeface cannot load them directly.

4. Sounds#

A notification sound rebuilds the default notification channel and future notifications; old channels are deleted. In-app sent/received sounds replace the SoundPool samples. Per-chat user sound settings take precedence over plugin global sounds. Reset rebuilds channels and reloads stock samples.

5. Wallpaper and chrome#

Wallpaper uses the existing Theme pipeline. A global font, sound or wallpaper may visually affect protected surfaces; that is the documented residual. Protected surfaces never receive plugin views or plugin data. Status and navigation bar colors require the chrome resource declaration.

6. Icons and strings#

IconKey is a stable host catalogue used by plugin UI, settings entries, the tab bar and the chat list. A plugin maps a key to a packaged image. Unknown keys are rejected. Protected and security UI uses a separate non-overridable icon set.

StringKey is an allowlist of non-security labels. Keys with prefixes login., passcode., payment., permission., consent., warning., secret. and plugin_manager. are rejected, as are keys marked security. String overrides never change the installer, consent, safe mode or plugin manager.

7. State and reset#

state() returns whether a provider is active, its plugin id, the overridden kinds and the apply timestamp. reset() pops the calling plugin. A failed apply leaves the current stack unchanged and completes the future exceptionally. Concurrent applies cannot land out of order.