From ef8ae53a22d460627c37e6d1492bac31fe6a24ee Mon Sep 17 00:00:00 2001 From: WizDom13 Date: Sat, 28 Nov 2026 01:07:57 +0200 Subject: [PATCH] Document and verify native plugin service icons --- .../PipePipePackageCompatibilityTest.kt | 9 +++++ docs/plugins.md | 32 ++++++++++++++++-- plugin-template/README.md | 19 +++++++++++ plugin-template/artwork/README.md | 18 ++++++++++ plugin-template/artwork/service-icon.svg | 6 ++++ plugin-template/build.gradle.kts | 25 ++++++++++++++ plugin-template/src/main/resources/icon.png | Bin 0 -> 3086 bytes .../src/main/resources/plugin.json | 1 + 8 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 plugin-template/artwork/README.md create mode 100644 plugin-template/artwork/service-icon.svg create mode 100644 plugin-template/src/main/resources/icon.png diff --git a/app/src/androidTest/java/org/schabi/newpipe/plugin/PipePipePackageCompatibilityTest.kt b/app/src/androidTest/java/org/schabi/newpipe/plugin/PipePipePackageCompatibilityTest.kt index 6bf465f3e00..975b37f8f1c 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/plugin/PipePipePackageCompatibilityTest.kt +++ b/app/src/androidTest/java/org/schabi/newpipe/plugin/PipePipePackageCompatibilityTest.kt @@ -7,6 +7,8 @@ package org.schabi.newpipe.plugin import android.content.Context import android.content.SharedPreferences +import android.graphics.BitmapFactory +import android.graphics.drawable.BitmapDrawable import android.os.Bundle import android.os.Parcel import androidx.preference.PreferenceManager @@ -361,6 +363,13 @@ class PipePipePackageCompatibilityTest { } assertEquals("wizestream", fixture.manifest.host) assertEquals("2.0", fixture.manifest.apiVersion) + assertEquals("icon.png", fixture.manifest.icon) + val encodedIcon = requireNotNull(PluginPackage.readIcon(fixture.file, fixture.manifest)) + val expectedIcon = requireNotNull(BitmapFactory.decodeByteArray(encodedIcon, 0, encodedIcon.size)) + val loadedIcon = PluginManager.getIcon(context, fixture.service.serviceId) as BitmapDrawable + assertEquals(256, loadedIcon.bitmap.width) + assertEquals(256, loadedIcon.bitmap.height) + assertTrue("The native service uses its signed package artwork", expectedIcon.sameAs(loadedIcon.bitmap)) assertEquals(1_772_767_428, fixture.service.serviceId) assertEquals("https://example.invalid/profile-fixture", fixture.service.baseUrl) assertEquals(profile.id, fixture.service.javaClass.getMethod("getBoundProfileId").invoke(fixture.service)) diff --git a/docs/plugins.md b/docs/plugins.md index 4baf58c84bc..91a783a2118 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -237,6 +237,7 @@ Its core fields are: "versionName": "1.0.0", "host": "wizestream", "apiVersion": "2.0", + "icon": "icon.png", "minHostVersionCode": 1052000, "minAndroidSdk": 24, "requiredCapabilities": ["profile-preferences"], @@ -283,8 +284,35 @@ settings and credentials; the host binds it to that profile. String and Boolean settings declared in `plugin.json` are rendered by the host. The context exposes their defaults and a change-listener interface. The settings screen also offers a restart -because some implementations cache their configuration. Optional icons are supported. Theme -color metadata is parsed, but this host retains WizeStream's own application theme. +because some implementations cache their configuration. Theme color metadata is parsed, but this +host retains WizeStream's own application theme. + +### Service icons + +A plugin can supply its service icon through the existing manifest field: + +```json +"icon": "icon.png" +``` + +Place that image at `src/main/resources/icon.png`, or use another package-relative +resource path and declare the same path in the manifest. The native template includes +an editable example vector and a 256 × 256 PNG. Replace the example with a +**single-color image on a transparent background**. The service selector tints its +icons, so an opaque background would hide the artwork under that tint. + +The encoded image must be no larger than **256 KiB**, with width and height each at +most **512 pixels**. PNG is recommended. The template's `pluginPackage` task checks +that the declared raster exists in the final archive, fits these limits, and decodes +successfully. An omitted or unusable icon falls back to the generic plugin symbol +without preventing an otherwise valid service from loading. + +WizeStream reads the image from the verified signed package and uses it in service +selection, the selected-service header, and relevant service pickers. No icon +download or additional plugin API is needed. Installation or update still requires a +restart before the new service artwork appears. Treat an icon change like any other +published package update: retain the plugin ID and signing key, increase `versionCode`, +and publish the matching signed package and catalog together. ### Shared libraries and packaging diff --git a/plugin-template/README.md b/plugin-template/README.md index 892c537ee59..35e8597960a 100644 --- a/plugin-template/README.md +++ b/plugin-template/README.md @@ -55,6 +55,25 @@ Set `ANDROID_HOME`, or put `sdk.dir=/absolute/path/android-sdk` in a local, untr Use `-PpluginSigningKey=/private/path/key.pk8` and `-PpluginPublicKey=/private/path/public.der` if keys are stored elsewhere. +## Give the service its own icon + +Replace `src/main/resources/icon.png` with your service's **square, single-color PNG +on a transparent background**. The sample is 256 × 256; the host accepts at most +512 × 512 pixels and 256 KiB. Do not add an opaque background: the service selector +tints the image for the active theme. The editable sample is +[`artwork/service-icon.svg`](artwork/service-icon.svg); rendering instructions are in +[artwork/README.md](artwork/README.md). + +Keep `"icon": "icon.png"` in `plugin.json`, or update it to the exact package-relative +path under `src/main/resources`. `pluginPackage` checks the final archive for the +declared image, validates its encoded size and dimensions, and decodes it before the +package can be signed. No new host API or remote icon URL is required. A missing icon +uses WizeStream's generic plugin symbol. + +After installation or update, restart WizeStream to load the new icon. Preserve the +plugin ID and signing key, and increase `versionCode` when changing artwork in an +already published plugin. + ## Replace the sample 1. Choose a permanent, unique `pluginId` and a service name that WizeStream does not already provide. diff --git a/plugin-template/artwork/README.md b/plugin-template/artwork/README.md new file mode 100644 index 00000000000..9637ace6dd8 --- /dev/null +++ b/plugin-template/artwork/README.md @@ -0,0 +1,18 @@ +# Example service icon + +`service-icon.svg` is the editable source for `../src/main/resources/icon.png`. +The PNG is a **256 × 256**, single-color image on a transparent background. WizeStream +tints service icons to match its light and dark themes; keep the background transparent. + +The SVG is original example artwork from WizeStream contributors, licensed under GPL-3.0-or-later. + +Render the checked-in PNG after changing the vector: + +```sh +inkscape artwork/service-icon.svg --export-type=png --export-width=256 --export-height=256 --export-filename=src/main/resources/icon.png +``` + +The build packages the existing PNG; it does not require Inkscape. The manifest's +`"icon": "icon.png"` refers to the path inside the signed `.ppp` archive. +`pluginPackage` checks that the declared raster is present, decodes successfully, is at +most **256 KiB**, and has dimensions no larger than **512 × 512**. diff --git a/plugin-template/artwork/service-icon.svg b/plugin-template/artwork/service-icon.svg new file mode 100644 index 00000000000..51efd625cc2 --- /dev/null +++ b/plugin-template/artwork/service-icon.svg @@ -0,0 +1,6 @@ + + Example streaming service icon + + + + diff --git a/plugin-template/build.gradle.kts b/plugin-template/build.gradle.kts index 8b73a9924a7..5fb2b16b53a 100644 --- a/plugin-template/build.gradle.kts +++ b/plugin-template/build.gradle.kts @@ -18,6 +18,7 @@ import java.security.spec.X509EncodedKeySpec import java.util.Base64 import java.util.Properties import java.util.zip.ZipFile +import javax.imageio.ImageIO plugins { `java-library` @@ -153,6 +154,30 @@ val pluginPackage by tasks.registering(Zip::class) { doLast { ZipFile(archiveFile.get().asFile).use { zip -> check(zip.getEntry("plugin.json") != null && zip.getEntry("classes.dex") != null) + (pluginManifest["icon"] as? String)?.let { iconPath -> + val iconEntry = checkNotNull(zip.getEntry(iconPath)) { + "Plugin package is missing its declared icon: $iconPath" + } + check(iconEntry.size in 1..(256L * 1024L)) { + "Plugin icon must be at most 256 KiB" + } + zip.getInputStream(iconEntry).use { source -> + ImageIO.createImageInputStream(source).use { imageInput -> + val readers = ImageIO.getImageReaders(imageInput) + check(readers.hasNext()) { "Plugin icon must be a decodable raster; use PNG" } + val reader = readers.next() + try { + reader.input = imageInput + check(reader.getWidth(0) in 1..512 && reader.getHeight(0) in 1..512) { + "Plugin icon dimensions must be at most 512 by 512 pixels" + } + check(reader.read(0) != null) { "Plugin icon cannot be decoded" } + } finally { + reader.dispose() + } + } + } + } val forbidden = listOf( "org/schabi/newpipe/", "kotlin/", diff --git a/plugin-template/src/main/resources/icon.png b/plugin-template/src/main/resources/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..66280930f0f98cc9ac9c4b224d9931a2079e8c5e GIT binary patch literal 3086 zcmbtWdpJ~E8((`iGZkiXL~dg=D&1U%jD)F%s6;MZ+$AH|8JAp!n8`WKlvJvdCd#;U znn)-iQM;s0HDz2Xb>a*Tl}tkoMv1d~zQ4ccIp6vI*y~;IZ~xZ2-nI97FGsw#Z`N3# zzW@NB;qFHF1^_~*5SWKWMPQ?P!;9Gw@&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