Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.
Python adbadblockandroid-tvandroid-tv-launcherapple-tvbloatware-removalclaude-codedebloatfire-tvgoogle-tvlauncherprivacysmart-tvsony-braviatclvibe-codingxiaomi
addons: add flocking simulation
maxsonferovanteee3a0bebe1b4
diff --git a/addons/README.md b/addons/README.mdindex c3f00031d..bb5d93537 100644--- a/addons/README.md+++ b/addons/README.md@@ -20,6 +20,7 @@ the core bigger or change how it behaves. You install an add-on only if you want| [TV Static](tv-static/) | An off-the-air moment each time the screen turns on: the picture opens from a bright line, snow and hiss, colour bars or an old "no signal" screen for 3 to 10 s, then fades into what was on screen; the card sets style, sound and length | [@luyzfernando08](https://github.com/luyzfernando08) | Xiaomi Mi Box S (Android TV 9), Philco by Skyworth (Android TV 14) | foreground service (screen-on watcher), start at boot, display over other apps | <img src="tv-static/screenshot.jpg" width="240" alt="TV Static on a TV"> || [Brightness](brightness/) | Dims the picture below the TV's own minimum over every app (and the picture settings on Realtek TVs), with a warm night mode on a schedule and a one-press normal screen | [@maxhayim](https://github.com/maxhayim) | MOKA R8G (Android 14) | overlay, foreground service, start at boot | <img src="brightness/screenshot.jpg" width="240" alt="Brightness on a TV"> || [Sleep Timer](sleep-timer/) | A sleep timer: 15 to 120 minutes, a one-minute countdown over what is playing with "15 more minutes", then standby; over HDMI-CEC the TV turns off with the box | [@luyzfernando08](https://github.com/luyzfernando08) | Xiaomi Mi Box S (Android TV 9) | accessibility (lock-screen action only), display over other apps, exact alarms | <img src="sleep-timer/screenshot.jpg" width="240" alt="Sleep Timer on a TV"> |+| [Flock](flock/) | An interactive flocking simulation using separation, alignment and cohesion, controlled with the TV remote | CleanYourTV contributors | TCL 32S5K (Android TV 14) | None | <img src="flock/screenshot.jpg" width="240" alt="Flock on TCL Android TV"> |A widget, an info tile, a storage or smart-home card: if it can live as its own small app, it can livehere. See the rules below.diff --git a/addons/flock/.gitignore b/addons/flock/.gitignorenew file mode 100644index 000000000..67bcc2f72--- /dev/null+++ b/addons/flock/.gitignore@@ -0,0 +1,2 @@+.gradle/+build/diff --git a/addons/flock/README.md b/addons/flock/README.mdnew file mode 100644index 000000000..6d63d6a54--- /dev/null+++ b/addons/flock/README.md@@ -0,0 +1,63 @@+# Flock++An interactive flocking simulation for Android TV. Each bird is an independent agent that reacts to+nearby birds; simple local rules produce the collective movement seen in flocks and schools of fish.+Open the **Flock** module card or the app to watch the simulation full screen.++## Screenshots on TV++Captured on a TCL 32S5K running Android TV 14 at 1280 × 720:++++++## How it works++The model implements the three classic boids rules:++- **Separation:** steers a bird away from very close neighbors.+- **Alignment:** turns it toward the average heading of nearby birds.+- **Cohesion:** steers it toward the local center of the group.++Each bird considers only neighbors inside a local radius. Position and velocity use elapsed frame time,+speed is capped to keep movement readable, and the screen edges wrap around. The simulation starts with+84 birds; the remote adjusts the flock from 24 to 180. Neighbor lookup is quadratic in flock size and+is capped at 180 agents.++## Controls++| Remote key | Action |+|---|---|+| **OK / Enter** | Pause or resume the simulation |+| **↑** | Add 12 birds, up to 180 |+| **↓** | Remove 12 birds, down to 24 |+| **Back** | Close the simulation |++All on-screen labels are in English.++## Install and run++Requires JDK 17 and Android SDK 34, like the other add-ons in this repository. From the repository root:++```sh+cd addons/flock+./gradlew --no-daemon testReleaseUnitTest assembleRelease+adb install -r app/build/outputs/apk/release/app-release.apk+adb shell am start -n io.github.cleanyourtv.flock/.FlockActivity+```++The app can also be opened from its module card. The launcher asks whether to show the card the first+time; you can change that choice later in **Module cards** in launcher settings.++## Permissions++None. The app does not access the network, files, or location, and it starts no background services.+The simulation and animation stop when the activity closes.++## Tested on++- **TCL 32S5K**, Android TV 14 / SDK 34, G13 platform, 1280 × 720.+- Installation and activity launch confirmed on the TV.+- OK paused and resumed the simulation; ↑ changed the count from 84 to 96; ↓ returned it from 96 to 84.+- The screenshots above show the running and paused states captured on the TV.diff --git a/addons/flock/app/build.gradle b/addons/flock/app/build.gradlenew file mode 100644index 000000000..9ebaf57ba--- /dev/null+++ b/addons/flock/app/build.gradle@@ -0,0 +1,34 @@+plugins {+ id 'com.android.application'+}++dependencies {+ testImplementation 'junit:junit:4.13.2'+}++android {+ namespace 'io.github.cleanyourtv.flock'+ compileSdk 34++ defaultConfig {+ applicationId 'io.github.cleanyourtv.flock'+ minSdk 26+ targetSdk 34+ versionCode 1+ versionName '1.0'+ }++ buildTypes {+ release {+ minifyEnabled true+ shrinkResources true+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'+ signingConfig signingConfigs.debug+ }+ }++ compileOptions {+ sourceCompatibility JavaVersion.VERSION_17+ targetCompatibility JavaVersion.VERSION_17+ }+}diff --git a/addons/flock/app/proguard-rules.pro b/addons/flock/app/proguard-rules.pronew file mode 100644index 000000000..e69de29bbdiff --git a/addons/flock/app/src/main/AndroidManifest.xml b/addons/flock/app/src/main/AndroidManifest.xmlnew file mode 100644index 000000000..48c876891--- /dev/null+++ b/addons/flock/app/src/main/AndroidManifest.xml@@ -0,0 +1,28 @@+<?xml version="1.0" encoding="utf-8"?>+<manifest xmlns:android="http://schemas.android.com/apk/res/android">+ <uses-feature android:name="android.software.leanback" android:required="false" />+ <uses-feature android:name="android.hardware.touchscreen" android:required="false" />++ <application+ android:allowBackup="false"+ android:banner="@drawable/banner"+ android:icon="@drawable/banner"+ android:label="@string/app_name"+ android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen">+ <activity+ android:name=".FlockActivity"+ android:configChanges="orientation|screenSize|keyboardHidden"+ android:exported="true"+ android:screenOrientation="landscape">+ <intent-filter>+ <action android:name="android.intent.action.MAIN" />+ <category android:name="android.intent.category.LEANBACK_LAUNCHER" />+ </intent-filter>+ <intent-filter>+ <action android:name="android.intent.action.MAIN" />+ <category android:name="com.gathin.tvhome.category.DOCK_CARD" />+ </intent-filter>+ <meta-data android:name="com.gathin.tvhome.card" android:resource="@xml/module_card" />+ </activity>+ </application>+</manifest>diff --git a/addons/flock/app/src/main/java/io/github/cleanyourtv/flock/FlockActivity.java b/addons/flock/app/src/main/java/io/github/cleanyourtv/flock/FlockActivity.javanew file mode 100644index 000000000..a9ed5e2e1--- /dev/null+++ b/addons/flock/app/src/main/java/io/github/cleanyourtv/flock/FlockActivity.java@@ -0,0 +1,53 @@+package io.github.cleanyourtv.flock;++import android.app.Activity;+import android.os.Bundle;+import android.view.KeyEvent;+import android.view.View;++/** Fullscreen TV entry point. All controls work with a standard D-pad remote. */+public final class FlockActivity extends Activity {+ private FlockView flockView;++ @Override+ protected void onCreate(Bundle savedInstanceState) {+ super.onCreate(savedInstanceState);+ getWindow().getDecorView().setSystemUiVisibility(+ View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);+ flockView = new FlockView(this);+ setContentView(flockView);+ }++ @Override+ protected void onResume() {+ super.onResume();+ if (flockView != null) flockView.resume();+ }++ @Override+ protected void onPause() {+ if (flockView != null) flockView.pause();+ super.onPause();+ }++ @Override+ public boolean onKeyDown(int keyCode, KeyEvent event) {+ if (event.getRepeatCount() == 0) {+ if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER+ || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {+ flockView.togglePaused();+ return true;+ }+ if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {+ flockView.changeCount(12);+ return true;+ }+ if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {+ flockView.changeCount(-12);+ return true;+ }+ }+ return super.onKeyDown(keyCode, event);+ }+}diff --git a/addons/flock/app/src/main/java/io/github/cleanyourtv/flock/FlockModel.java b/addons/flock/app/src/main/java/io/github/cleanyourtv/flock/FlockModel.javanew file mode 100644index 000000000..89eced63d--- /dev/null+++ b/addons/flock/app/src/main/java/io/github/cleanyourtv/flock/FlockModel.java@@ -0,0 +1,175 @@+package io.github.cleanyourtv.flock;++import java.util.ArrayList;+import java.util.List;+import java.util.Random;++/** Lightweight Reynolds-style boids simulation with wraparound edges. */+final class FlockModel {+ private static final float MIN_SPEED = 48f;+ private static final float MAX_SPEED = 112f;+ private static final float SEPARATION_WEIGHT = 1.65f;+ private static final float ALIGNMENT_WEIGHT = 0.95f;+ private static final float COHESION_WEIGHT = 0.8f;++ private final Random random = new Random();+ private final List<Boid> boids = new ArrayList<>();+ private float width;+ private float height;++ FlockModel(int count) {+ setCount(count);+ }++ int size() {+ return boids.size();+ }++ Boid boidAt(int index) {+ return boids.get(index);+ }++ void resize(float width, float height) {+ boolean firstLayout = this.width <= 1f && this.height <= 1f;+ this.width = Math.max(1f, width);+ this.height = Math.max(1f, height);+ for (Boid boid : boids) {+ if (firstLayout) {+ boid.x = random.nextFloat() * this.width;+ boid.y = random.nextFloat() * this.height;+ } else {+ boid.x = wrap(boid.x, this.width);+ boid.y = wrap(boid.y, this.height);+ }+ }+ }++ void setCount(int count) {+ count = Math.max(24, Math.min(180, count));+ while (boids.size() > count) boids.remove(boids.size() - 1);+ while (boids.size() < count) {+ float x = random.nextFloat() * Math.max(1f, width);+ float y = random.nextFloat() * Math.max(1f, height);+ float angle = random.nextFloat() * (float) (Math.PI * 2);+ float speed = MIN_SPEED + random.nextFloat() * (MAX_SPEED - MIN_SPEED);+ boids.add(new Boid(x, y, (float) Math.cos(angle) * speed, (float) Math.sin(angle) * speed));+ }+ }++ void step(float elapsedSeconds) {+ if (boids.isEmpty() || width <= 1f || height <= 1f) return;+ float dt = Math.min(0.04f, Math.max(0f, elapsedSeconds));+ if (dt == 0f) return;++ int count = boids.size();+ float[] x = new float[count], y = new float[count], vx = new float[count], vy = new float[count];+ for (int i = 0; i < count; i++) {+ Boid boid = boids.get(i);+ x[i] = boid.x;+ y[i] = boid.y;+ vx[i] = boid.vx;+ vy[i] = boid.vy;+ }++ float neighborRadius = Math.min(width, height) * 0.15f;+ float neighborRadiusSq = neighborRadius * neighborRadius;+ float separationRadius = neighborRadius * 0.34f;+ float separationRadiusSq = separationRadius * separationRadius;+ float[] acceleration = new float[2];+ for (int i = 0; i < count; i++) {+ float centerX = 0f, centerY = 0f, headingX = 0f, headingY = 0f;+ float separateX = 0f, separateY = 0f;+ int neighbors = 0, closeNeighbors = 0;+ for (int j = 0; j < count; j++) {+ if (i == j) continue;+ float dx = shortestDelta(x[j] - x[i], width);+ float dy = shortestDelta(y[j] - y[i], height);+ float distanceSq = dx * dx + dy * dy;+ if (distanceSq > neighborRadiusSq || distanceSq < 0.0001f) continue;+ centerX += dx;+ centerY += dy;+ headingX += vx[j];+ headingY += vy[j];+ neighbors++;+ if (distanceSq < separationRadiusSq) {+ float distance = (float) Math.sqrt(distanceSq);+ separateX -= dx / distance;+ separateY -= dy / distance;+ closeNeighbors++;+ }+ }++ acceleration[0] = 0f;+ acceleration[1] = 0f;+ if (neighbors > 0) {+ // Cohesion steers toward the local centre; alignment matches nearby heading.+ addSteering(centerX / neighbors, centerY / neighbors, vx[i], vy[i], COHESION_WEIGHT, acceleration);+ addSteering(headingX / neighbors - vx[i], headingY / neighbors - vy[i], vx[i], vy[i],+ ALIGNMENT_WEIGHT, acceleration);+ }+ if (closeNeighbors > 0) {+ addSteering(separateX / closeNeighbors, separateY / closeNeighbors, vx[i], vy[i],+ SEPARATION_WEIGHT, acceleration);+ }++ Boid boid = boids.get(i);+ float nextVx = vx[i] + acceleration[0] * dt;+ float nextVy = vy[i] + acceleration[1] * dt;+ float speed = length(nextVx, nextVy);+ if (speed < 0.001f) {+ nextVx = vx[i];+ nextVy = vy[i];+ speed = length(nextVx, nextVy);+ }+ float targetSpeed = Math.max(MIN_SPEED, Math.min(MAX_SPEED, speed));+ boid.vx = nextVx / speed * targetSpeed;+ boid.vy = nextVy / speed * targetSpeed;+ boid.x = wrap(x[i] + boid.vx * dt, width);+ boid.y = wrap(y[i] + boid.vy * dt, height);+ }+ }++ private static void addSteering(float desiredX, float desiredY, float vx, float vy,+ float weight, float[] acceleration) {+ float magnitude = length(desiredX, desiredY);+ if (magnitude < 0.001f) return;+ float targetX = desiredX / magnitude * MAX_SPEED;+ float targetY = desiredY / magnitude * MAX_SPEED;+ float steerX = targetX - vx;+ float steerY = targetY - vy;+ float steerLength = length(steerX, steerY);+ float maxForce = MAX_SPEED * 0.8f;+ if (steerLength > maxForce) {+ steerX = steerX / steerLength * maxForce;+ steerY = steerY / steerLength * maxForce;+ }+ acceleration[0] += steerX * weight;+ acceleration[1] += steerY * weight;+ }++ private static float length(float x, float y) {+ return (float) Math.sqrt(x * x + y * y);+ }++ private static float shortestDelta(float delta, float extent) {+ if (delta > extent / 2f) return delta - extent;+ if (delta < -extent / 2f) return delta + extent;+ return delta;+ }++ private static float wrap(float value, float extent) {+ value %= extent;+ return value < 0f ? value + extent : value;+ }++ static final class Boid {+ float x, y, vx, vy;++ Boid(float x, float y, float vx, float vy) {+ this.x = x;+ this.y = y;+ this.vx = vx;+ this.vy = vy;+ }+ }+}diff --git a/addons/flock/app/src/main/java/io/github/cleanyourtv/flock/FlockView.java b/addons/flock/app/src/main/java/io/github/cleanyourtv/flock/FlockView.javanew file mode 100644index 000000000..3e2dddd0b--- /dev/null+++ b/addons/flock/app/src/main/java/io/github/cleanyourtv/flock/FlockView.java@@ -0,0 +1,165 @@+package io.github.cleanyourtv.flock;++import android.content.Context;+import android.graphics.Canvas;+import android.graphics.LinearGradient;+import android.graphics.Paint;+import android.graphics.Path;+import android.graphics.Shader;+import android.os.SystemClock;+import android.view.View;++/** Canvas renderer and frame-clock for the flock; the simulation runs only while this screen is visible. */+final class FlockView extends View {+ private static final int MIN_BOIDS = 24;+ private static final int MAX_BOIDS = 180;+ private static final int[] PALETTE = {0xFF70E1CF, 0xFF9BBEFF, 0xFFFFD28A, 0xFFE5F3F1};++ private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);+ private final Paint backgroundPaint = new Paint();+ private final Path bird = new Path();+ private final FlockModel model = new FlockModel(84);+ private final float density;+ private final String runningLabel;+ private final String pausedLabel;+ private final String controls;+ private boolean running;+ private boolean paused;+ private long previousFrame;++ FlockView(Context context) {+ super(context);+ density = getResources().getDisplayMetrics().density;+ runningLabel = context.getString(R.string.running);+ pausedLabel = context.getString(R.string.paused);+ controls = context.getString(R.string.controls);+ setFocusable(false);+ setContentDescription(context.getString(R.string.app_name) + ". " + controls);+ }++ void resume() {+ running = true;+ previousFrame = SystemClock.uptimeMillis();+ postInvalidateOnAnimation();+ }++ void pause() {+ running = false;+ }++ void togglePaused() {+ paused = !paused;+ invalidate();+ }++ void changeCount(int amount) {+ model.setCount(Math.max(MIN_BOIDS, Math.min(MAX_BOIDS, model.size() + amount)));+ invalidate();+ }++ @Override+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {+ model.resize(w, h);+ backgroundPaint.setShader(new LinearGradient(0, 0, w, h, 0xFF071820, 0xFF10232C,+ Shader.TileMode.CLAMP));+ }++ @Override+ protected void onDraw(Canvas canvas) {+ super.onDraw(canvas);+ int width = getWidth(), height = getHeight();+ canvas.drawRect(0, 0, width, height, backgroundPaint);+ drawAmbientDots(canvas, width, height);++ if (running && !paused) {+ long now = SystemClock.uptimeMillis();+ float dt = (now - previousFrame) / 1000f;+ previousFrame = now;+ model.step(dt);+ }+ drawBoids(canvas);+ drawHud(canvas, width, height);+ if (running && !paused) postInvalidateOnAnimation();+ }++ private void drawAmbientDots(Canvas canvas, int width, int height) {+ paint.setStyle(Paint.Style.FILL);+ for (int i = 0; i < 28; i++) {+ float x = ((i * 97 + 31) % 997) / 997f * width;+ float y = ((i * 193 + 71) % 991) / 991f * height;+ paint.setColor(i % 4 == 0 ? 0x1E8CC8C0 : 0x16FFFFFF);+ canvas.drawCircle(x, y, (i % 3 + 1) * density, paint);+ }+ }++ private void drawBoids(Canvas canvas) {+ for (int i = 0; i < model.size(); i++) {+ FlockModel.Boid boid = model.boidAt(i);+ float heading = (float) Math.atan2(boid.vy, boid.vx);+ float c = (float) Math.cos(heading), s = (float) Math.sin(heading);+ float noseX = boid.x + c * 11f * density;+ float noseY = boid.y + s * 11f * density;+ float rearX = boid.x - c * 8f * density;+ float rearY = boid.y - s * 8f * density;+ float sideX = -s * 5f * density;+ float sideY = c * 5f * density;++ paint.setColor(0x426EDBCB);+ paint.setStrokeWidth(1.5f * density);+ paint.setStrokeCap(Paint.Cap.ROUND);+ canvas.drawLine(rearX - c * 8f * density, rearY - s * 8f * density,+ rearX, rearY, paint);++ bird.reset();+ bird.moveTo(noseX, noseY);+ bird.lineTo(rearX + sideX, rearY + sideY);+ bird.lineTo(boid.x - c * 1f * density, boid.y - s * 1f * density);+ bird.lineTo(rearX - sideX, rearY - sideY);+ bird.close();+ paint.setColor(PALETTE[i % PALETTE.length]);+ canvas.drawPath(bird, paint);+ }+ }++ private void drawHud(Canvas canvas, int width, int height) {+ float margin = 36f * density;+ paint.setStyle(Paint.Style.FILL);+ paint.setTypeface(android.graphics.Typeface.create("sans-serif", android.graphics.Typeface.NORMAL));+ paint.setTextAlign(Paint.Align.LEFT);+ paint.setTextSize(15f * density);+ String status = paused ? pausedLabel : runningLabel;+ float statusWidth = paint.measureText(status);+ paint.setColor(0xE617303A);+ canvas.drawRoundRect(margin - 12f * density, margin - 8f * density,+ margin + statusWidth + 12f * density, margin + 24f * density,+ 12f * density, 12f * density, paint);+ paint.setColor(0xBFE9F5F2);+ canvas.drawText(status, margin, margin + 15f * density, paint);++ String count = getResources().getQuantityString(R.plurals.birds, model.size(), model.size());+ paint.setTextAlign(Paint.Align.RIGHT);+ float countWidth = paint.measureText(count);+ paint.setColor(0xE617303A);+ canvas.drawRoundRect(width - margin - countWidth - 12f * density, margin - 8f * density,+ width - margin + 12f * density, margin + 24f * density,+ 12f * density, 12f * density, paint);+ paint.setColor(0xAFC8D9D5);+ canvas.drawText(count, width - margin, margin + 15f * density, paint);++ paint.setTextAlign(Paint.Align.CENTER);+ paint.setTextSize(14f * density);+ float controlsWidth = paint.measureText(controls);+ paint.setColor(0xD9142932);+ canvas.drawRoundRect(width / 2f - controlsWidth / 2f - 16f * density,+ height - margin - 18f * density, width / 2f + controlsWidth / 2f + 16f * density,+ height - margin + 7f * density, 12f * density, 12f * density, paint);+ paint.setColor(0x80E9F5F2);+ canvas.drawText(controls, width / 2f, height - margin, paint);++ if (paused) {+ paint.setTextSize(22f * density);+ paint.setColor(0xFFF1F8F6);+ canvas.drawText(pausedLabel, width / 2f, height / 2f, paint);+ }+ }+}diff --git a/addons/flock/app/src/main/res/drawable/banner.xml b/addons/flock/app/src/main/res/drawable/banner.xmlnew file mode 100644index 000000000..0d528e3c4--- /dev/null+++ b/addons/flock/app/src/main/res/drawable/banner.xml@@ -0,0 +1,6 @@+<?xml version="1.0" encoding="utf-8"?>+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ android:width="320dp" android:height="180dp" android:viewportWidth="320" android:viewportHeight="180">+ <path android:fillColor="#071820" android:pathData="M0,0h320v180h-320z" />+ <path android:fillColor="#65D6C2" android:pathData="M73,72l25,10l-25,10l6,-10zM118,49l22,9l-22,9l5,-9zM148,91l28,11l-28,11l6,-11zM193,58l24,9l-24,9l5,-9zM220,101l25,10l-25,10l6,-10zM105,119l21,8l-21,8l5,-8zM176,125l19,8l-19,8l5,-8zM255,72l21,8l-21,8l5,-8z" />+</vector>diff --git a/addons/flock/app/src/main/res/values/strings.xml b/addons/flock/app/src/main/res/values/strings.xmlnew file mode 100644index 000000000..3392d050d--- /dev/null+++ b/addons/flock/app/src/main/res/values/strings.xml@@ -0,0 +1,10 @@+<resources>+ <string name="app_name">Flock</string>+ <string name="paused">Paused</string>+ <string name="running">Flocking</string>+ <string name="controls">OK Pause · ↑ More birds · ↓ Fewer birds · Back Exit</string>+ <plurals name="birds">+ <item quantity="one">%1$d bird</item>+ <item quantity="other">%1$d birds</item>+ </plurals>+</resources>diff --git a/addons/flock/app/src/main/res/xml/module_card.xml b/addons/flock/app/src/main/res/xml/module_card.xmlnew file mode 100644index 000000000..f92e96aa7--- /dev/null+++ b/addons/flock/app/src/main/res/xml/module_card.xml@@ -0,0 +1,2 @@+<?xml version="1.0" encoding="utf-8"?>+<card spec="1" label="Flock" caption="Boid simulation" accent="#65D6C2" />diff --git a/addons/flock/app/src/test/java/io/github/cleanyourtv/flock/FlockModelTest.java b/addons/flock/app/src/test/java/io/github/cleanyourtv/flock/FlockModelTest.javanew file mode 100644index 000000000..c54f9a059--- /dev/null+++ b/addons/flock/app/src/test/java/io/github/cleanyourtv/flock/FlockModelTest.java@@ -0,0 +1,97 @@+package io.github.cleanyourtv.flock;++import org.junit.Test;++import static org.junit.Assert.assertEquals;+import static org.junit.Assert.assertTrue;++public class FlockModelTest {+ private static final float WIDTH = 6400f;+ private static final float HEIGHT = 1600f;+ private static final float EPSILON = 0.001f;++ @Test+ public void countStaysWithinSupportedLimits() {+ FlockModel model = new FlockModel(84);++ model.setCount(0);+ assertEquals(24, model.size());+ model.setCount(999);+ assertEquals(180, model.size());+ model.setCount(96);+ assertEquals(96, model.size());+ }++ @Test+ public void cohesionSteersAnAgentTowardNearbyFlockmates() {+ FlockModel model = separatedModel();+ place(model, 0, 200f, 200f, 50f, 0f);+ place(model, 1, 300f, 200f, 50f, 0f);++ model.step(0.04f);++ assertTrue("cohesion should increase the agent's velocity toward its neighbor",+ model.boidAt(0).vx > 50f);+ }++ @Test+ public void separationMovesAgentsApartAndAlignmentSharesHeading() {+ FlockModel model = separatedModel();+ place(model, 0, 200f, 200f, 50f, 0f);+ place(model, 1, 210f, 200f, 0f, 50f);++ model.step(0.04f);++ assertTrue("separation should steer away from the close neighbor", model.boidAt(0).vx < 50f);+ assertTrue("alignment should turn toward the neighbor's upward heading", model.boidAt(0).vy > 0f);+ }++ @Test+ public void crossingAnEdgeWrapsToTheOppositeSide() {+ FlockModel model = separatedModel();+ place(model, 0, WIDTH - 1f, 200f, 100f, 0f);++ model.step(0.04f);++ assertTrue(model.boidAt(0).x >= 0f);+ assertTrue("the agent should wrap near the left edge", model.boidAt(0).x < 10f);+ }++ @Test+ public void agentsRemainFiniteBoundedAndWithinSpeedLimits() {+ FlockModel model = new FlockModel(84);+ model.resize(WIDTH, HEIGHT);++ for (int frame = 0; frame < 250; frame++) model.step(1f / 60f);++ for (int i = 0; i < model.size(); i++) {+ FlockModel.Boid boid = model.boidAt(i);+ assertTrue(Float.isFinite(boid.x));+ assertTrue(Float.isFinite(boid.y));+ assertTrue(Float.isFinite(boid.vx));+ assertTrue(Float.isFinite(boid.vy));+ assertTrue(boid.x >= 0f && boid.x < WIDTH);+ assertTrue(boid.y >= 0f && boid.y < HEIGHT);+ float speed = (float) Math.hypot(boid.vx, boid.vy);+ assertTrue(speed >= 48f - EPSILON);+ assertTrue(speed <= 112f + EPSILON);+ }+ }++ private static FlockModel separatedModel() {+ FlockModel model = new FlockModel(24);+ model.resize(WIDTH, HEIGHT);+ for (int i = 0; i < model.size(); i++) {+ place(model, i, 700f + (i - 2) * 250f, 1000f, 50f, 0f);+ }+ return model;+ }++ private static void place(FlockModel model, int index, float x, float y, float vx, float vy) {+ FlockModel.Boid boid = model.boidAt(index);+ boid.x = x;+ boid.y = y;+ boid.vx = vx;+ boid.vy = vy;+ }+}diff --git a/addons/flock/build.gradle b/addons/flock/build.gradlenew file mode 100644index 000000000..48978475f--- /dev/null+++ b/addons/flock/build.gradle@@ -0,0 +1,3 @@+plugins {+ id 'com.android.application' version '8.5.2' apply false+}diff --git a/addons/flock/gradle.properties b/addons/flock/gradle.propertiesnew file mode 100644index 000000000..18825f968--- /dev/null+++ b/addons/flock/gradle.properties@@ -0,0 +1,3 @@+org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8+android.useAndroidX=true+android.nonTransitiveRClass=truediff --git a/addons/flock/gradlew b/addons/flock/gradlewnew file mode 100755index 000000000..fbcfb4bcb--- /dev/null+++ b/addons/flock/gradlew@@ -0,0 +1,4 @@+#!/bin/sh+# Reuse the repository's pinned Gradle distribution, but build this independent project.+addon_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) || exit 1+exec sh "$addon_dir/../../launcher/gradlew" -p "$addon_dir" "$@"diff --git a/addons/flock/screenshot-paused.jpg b/addons/flock/screenshot-paused.jpgnew file mode 100644index 000000000..8385891f4Binary files /dev/null and b/addons/flock/screenshot-paused.jpg differdiff --git a/addons/flock/screenshot.jpg b/addons/flock/screenshot.jpgnew file mode 100644index 000000000..463cfba2dBinary files /dev/null and b/addons/flock/screenshot.jpg differdiff --git a/addons/flock/settings.gradle b/addons/flock/settings.gradlenew file mode 100644index 000000000..ca3637f49--- /dev/null+++ b/addons/flock/settings.gradle@@ -0,0 +1,16 @@+pluginManagement {+ repositories {+ google()+ mavenCentral()+ gradlePluginPortal()+ }+}+dependencyResolutionManagement {+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)+ repositories {+ google()+ mavenCentral()+ }+}+rootProject.name = "flock"+include ':app'diff --git a/tests/test_addons.py b/tests/test_addons.pyindex a4451c65a..de35ea14a 100644--- a/tests/test_addons.py+++ b/tests/test_addons.py@@ -41,7 +41,9 @@ class AddonIsolationTest(unittest.TestCase):self.assertNotRegex(text, r"(\.\./)+addons/|\baddons/", f"{path.relative_to(ROOT)} refers to addons/")def test_no_prebuilt_apks(self):- apks = [str(p.relative_to(ROOT)) for p in ADDONS.rglob("*.apk")] if ADDONS.is_dir() else []+ # Gradle's ignored build outputs are expected after compiling or testing an add-on.+ apks = [str(p.relative_to(ROOT)) for p in ADDONS.rglob("*.apk")+ if "build" not in p.relative_to(ADDONS).parts] if ADDONS.is_dir() else []self.assertEqual(apks, [], "no prebuilt APKs in addons/")