Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

Launcher: a Halloween skin (seasonal_skin or festival "halloween"): a jack-o'-lantern Wi-Fi icon whose face glows while online, a bat for Inputs, a ghost for Settings, bats flying up over the first Home of the day, "Happy Halloween" and a pumpkin glow; icons from Fluent Emoji 3D (MIT)

Gathin23959a9fb73e0f
diff --git a/launcher/ICONS-LICENSE-FLUENT-EMOJI.txt b/launcher/ICONS-LICENSE-FLUENT-EMOJI.txt
new file mode 100644
index 000000000..c65247e08
--- /dev/null
+++ b/launcher/ICONS-LICENSE-FLUENT-EMOJI.txt
@@ -0,0 +1,27 @@
+The Halloween skin's pictures in app/src/main/res/drawable-nodpi/ (halloween_pumpkin_lit.webp,
+halloween_pumpkin_dark.webp, halloween_bat.webp, halloween_ghost.webp) are from Microsoft's Fluent Emoji 3D
+(https://github.com/microsoft/fluentui-emoji: Jack-o-lantern, Bat, Ghost), resized to WebP. The lit and dark pumpkins
+are the same picture with the carved face recoloured as a candle-lit and an unlit face. Fluent Emoji is under the MIT
+licence below.
+
+MIT License
+
+Copyright (c) Microsoft Corporation.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/BatFlightView.java b/launcher/app/src/main/java/com/gathin/tvhome/BatFlightView.java
new file mode 100644
index 000000000..732784e0b
--- /dev/null
+++ b/launcher/app/src/main/java/com/gathin/tvhome/BatFlightView.java
@@ -0,0 +1,141 @@
+package com.gathin.tvhome;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.RectF;
+import android.os.SystemClock;
+import android.view.View;
+
+import java.util.Random;
+
+/**
+ * The Halloween skin's greeting for the first Home of the day: a transparent full-screen overlay where a colony of
+ * bats rises from the bottom of the screen and scatters out over the top, beating their wings, then the callback
+ * runs on the main thread. The bat is a picture (Microsoft's Fluent Emoji 3D, MIT), squeezed in time with each
+ * wing beat and mirrored for half the colony. Like {@link PetalShowerView} it takes no focus, clicks or
+ * accessibility and allocates nothing per frame.
+ */
+public final class BatFlightView extends View {
+
+ private static final double TAU = 2 * Math.PI;
+
+ private final float density;
+ private final Bitmap bat;
+ private final Random rnd = new Random();
+ private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
+ private final RectF dst = new RectF();
+
+ private int count;
+ private float[] x0 = new float[0], drift = new float[0], delay = new float[0], life = new float[0],
+ size = new float[0], beatHz = new float[0], phase = new float[0], weave = new float[0];
+ private boolean[] mirror = new boolean[0];
+
+ private boolean playing;
+ private long start, duration;
+ private Runnable onDone;
+ private final Runnable finish = this::finish;
+
+ public BatFlightView(Context context) {
+ super(context);
+ density = context.getResources().getDisplayMetrics().density;
+ bat = BitmapFactory.decodeResource(context.getResources(), R.drawable.halloween_bat);
+ setFocusable(false);
+ setClickable(false);
+ setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
+ setWillNotDraw(false);
+ }
+
+ /**
+ * Sends {@code bats} bats up over {@code durationMs}, then runs {@code done} on the main thread. Playing again
+ * before the last flight ends finishes that one first (its callback runs).
+ */
+ public void play(int bats, long durationMs, Runnable done) {
+ if (playing) {
+ removeCallbacks(finish);
+ finish();
+ }
+ int n = Math.max(0, bats);
+ ensureCapacity(n);
+ count = n;
+ duration = Math.max(1, durationMs);
+ onDone = done;
+ for (int i = 0; i < n; i++) {
+ x0[i] = (i + rnd.nextFloat()) / n; // spread across the width
+ drift[i] = (rnd.nextFloat() - 0.5f) * 0.5f; // fraction of the width moved sideways
+ delay[i] = rnd.nextFloat() * 0.35f; // fractions of the duration
+ life[i] = 0.55f + rnd.nextFloat() * (1f - delay[i] - 0.55f);
+ size[i] = 26f + rnd.nextFloat() * 30f; // dp
+ beatHz[i] = 5f + rnd.nextFloat() * 3f;
+ phase[i] = rnd.nextFloat() * (float) TAU;
+ weave[i] = 8f + rnd.nextFloat() * 18f; // dp of side-to-side weave
+ mirror[i] = drift[i] < 0f; // face the way it is heading
+ }
+ playing = true;
+ start = SystemClock.uptimeMillis();
+ postDelayed(finish, duration);
+ postInvalidateOnAnimation();
+ }
+
+ private void finish() {
+ if (!playing) return;
+ playing = false;
+ invalidate();
+ Runnable done = onDone;
+ onDone = null;
+ if (done != null) done.run();
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ if (playing) {
+ removeCallbacks(finish);
+ finish();
+ }
+ }
+
+ @Override
+ protected void onDraw(Canvas c) {
+ if (!playing) return;
+ long now = SystemClock.uptimeMillis();
+ float elapsed = (now - start) / (float) duration;
+ float secs = (now - start) / 1000f;
+ float w = getWidth(), h = getHeight();
+ for (int i = 0; i < count; i++) {
+ float p = (elapsed - delay[i]) / life[i];
+ if (p <= 0f || p >= 1f) continue;
+ float s = size[i] * density;
+ float rise = p * (0.6f + 0.4f * p); // takes off, then speeds up
+ float y = h + s - (h + 2.5f * s) * rise;
+ float x = (x0[i] + drift[i] * p) * w
+ + weave[i] * density * (float) Math.sin(TAU * 0.8 * secs + phase[i]);
+ float beat = (float) Math.sin(TAU * beatHz[i] * secs + phase[i]);
+ float sy = 0.62f + 0.38f * Math.abs(beat); // wings folding and opening
+ int a = p < 0.12f ? (int) (255 * p / 0.12f) : p > 0.8f ? (int) (255 * (1f - (p - 0.8f) / 0.2f)) : 255;
+ paint.setAlpha(a);
+ c.save();
+ c.translate(x, y);
+ c.scale(mirror[i] ? -1f : 1f, sy);
+ dst.set(-s / 2f, -s / 2f, s / 2f, s / 2f);
+ c.drawBitmap(bat, null, dst, paint);
+ c.restore();
+ }
+ postInvalidateOnAnimation();
+ }
+
+ private void ensureCapacity(int n) {
+ if (x0.length >= n) return;
+ x0 = new float[n];
+ drift = new float[n];
+ delay = new float[n];
+ life = new float[n];
+ size = new float[n];
+ beatHz = new float[n];
+ phase = new float[n];
+ weave = new float[n];
+ mirror = new boolean[n];
+ }
+}
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Config.java b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
index 8f923fceb..eaccada9e 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -669,8 +669,9 @@ final class Config {
wallpaper = chosen.isEmpty() ? null : chosen.get(0);
wallpaperEnabled = !chosen.isEmpty();
}
- // A festive skin comes only from a theme; config.xml has no festival.
- Festival festival = json == null ? Festival.NONE : Festival.parse(string(json, "festival", ""),
+ // A festive skin comes only from a theme; config.xml has no festival. seasonal_skin names one the same way
+ // but launchers before it ignore the key, so a theme can carry it without older ones showing the diya skin.
+ Festival festival = json == null ? Festival.NONE : Festival.parse(festivalName(json),
string(json, "festival_until", ""), string(json, "greeting", ""), string(json, "accent_color", ""));
return new Config(dock, fillDock, hidden, libraryApps, libraryExcludedApps, liveTv, liveTvAction, liveTvInputId, packageMap(launchActions), packageMap(appLabels),
@@ -832,6 +833,12 @@ final class Config {
return v instanceof String ? ((String) v).trim() : fallback;
}
+ /** The theme's festival: {@code festival}, or {@code seasonal_skin} when that is empty or missing. */
+ static String festivalName(JSONObject o) {
+ String name = string(o, "festival", "");
+ return name.isEmpty() ? string(o, "seasonal_skin", "") : name;
+ }
+
private static boolean bool(JSONObject o, String key, boolean fallback) {
Object v = o.opt(key);
return v instanceof Boolean ? (Boolean) v : fallback;
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/DiyaDrawable.java b/launcher/app/src/main/java/com/gathin/tvhome/DiyaDrawable.java
index a4ce625d8..6ebfe75c1 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/DiyaDrawable.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/DiyaDrawable.java
@@ -11,7 +11,6 @@ import android.graphics.RadialGradient;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
-import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
@@ -27,7 +26,7 @@ import java.util.Random;
* frosted and on the white (focused) pill. The flame flickers only while started, at about 15 fps; nothing is
* allocated per frame. The first {@link #setFlame} call applies its level without an animation.
*/
-public final class DiyaDrawable extends Drawable implements Animatable {
+public final class DiyaDrawable extends Drawable implements FestiveLamp {
private static final float BOX = 24f;
private static final long FRAME_MS = 66;
@@ -144,6 +143,7 @@ public final class DiyaDrawable extends Drawable implements Animatable {
// ---- public API ----
/** 0 puts the flame out; 1 to 4 is the signal strength, which sets the flame's height. */
+ @Override
public void setFlame(int newLevel) {
int lvl = Math.max(0, Math.min(4, newLevel));
if (!primed) {
@@ -179,6 +179,7 @@ public final class DiyaDrawable extends Drawable implements Animatable {
}
/** A steady flame (Ethernet) only breathes slowly and does not sway. */
+ @Override
public void setSteady(boolean steady) {
if (this.steady == steady) return;
this.steady = steady;
@@ -186,6 +187,7 @@ public final class DiyaDrawable extends Drawable implements Animatable {
}
/** With reduced motion the flame is still, there is no smoke or spark, and level changes are instant. */
+ @Override
public void setReducedMotion(boolean reducedMotion) {
if (reduced == reducedMotion) return;
reduced = reducedMotion;
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Festival.java b/launcher/app/src/main/java/com/gathin/tvhome/Festival.java
index 148ff5049..1be6404e5 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Festival.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Festival.java
@@ -7,10 +7,11 @@ import java.time.format.DateTimeParseException;
import java.util.Locale;
/**
- * A festive skin set by a theme's config.json: {@code festival}, {@code festival_until}, {@code greeting}
- * and {@code accent_color}. While it is active the pills get festive icons (a diya for the network, a bell
- * for Inputs, a marigold for Settings), the greeting is replaced and the focus glow takes the accent colour.
- * It switches itself off after {@code festival_until}, so nobody has to remember to undo it.
+ * A festive skin set by a theme's config.json: {@code festival} (or {@code seasonal_skin}), {@code festival_until},
+ * {@code greeting} and {@code accent_color}. While it is active the pills get festive icons (a diya for the
+ * network, a bell for Inputs, a marigold for Settings; for {@code halloween} a jack-o'-lantern, a bat and a
+ * ghost), the greeting is replaced and the focus glow takes the accent colour. It switches itself off after
+ * {@code festival_until}, so nobody has to remember to undo it.
*/
final class Festival {
@@ -19,6 +20,12 @@ final class Festival {
/** Warm diya gold, the accent when a theme names a festival but no colour. */
static final int DEFAULT_ACCENT = 0xFFFFB23C;
+ /** The festival with its own skin (jack-o'-lantern, bat, ghost, bats on the first Home) instead of the diya's. */
+ static final String HALLOWEEN = "halloween";
+
+ /** Pumpkin orange, Halloween's accent when the theme names no colour. */
+ static final int PUMPKIN = 0xFFFF7A1A;
+
/** Lower-case festival name, or "" for none. */
final String name;
/** Last day the skin shows, inclusive; null for no end date. */
@@ -67,13 +74,21 @@ final class Festival {
return res.getString(R.string.festival_dussehra_greeting);
case "diwali":
return res.getString(R.string.festival_diwali_greeting);
+ case HALLOWEEN:
+ return res.getString(R.string.festival_halloween_greeting);
default:
return "";
}
}
int accentColor() {
- return accent != 0 ? accent : DEFAULT_ACCENT;
+ if (accent != 0) return accent;
+ return isHalloween() ? PUMPKIN : DEFAULT_ACCENT;
+ }
+
+ /** Whether this is the Halloween skin rather than the diya, bell and marigold. */
+ boolean isHalloween() {
+ return HALLOWEEN.equals(name);
}
/** {@code #RRGGBB} to an opaque colour, anything else to 0. */
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/FestiveLamp.java b/launcher/app/src/main/java/com/gathin/tvhome/FestiveLamp.java
new file mode 100644
index 000000000..2fde4ea80
--- /dev/null
+++ b/launcher/app/src/main/java/com/gathin/tvhome/FestiveLamp.java
@@ -0,0 +1,19 @@
+package com.gathin.tvhome;
+
+import android.graphics.drawable.Animatable;
+
+/**
+ * The network pill's icon while a festive skin is on: a light that follows the connection. The diya's flame and
+ * the jack-o'-lantern's candle both take the same calls from the Wi-Fi label code.
+ */
+interface FestiveLamp extends Animatable {
+
+ /** 0 puts the light out (offline); 1 to 4 is the signal strength. */
+ void setFlame(int level);
+
+ /** A steady light (Ethernet) does not flicker. */
+ void setSteady(boolean steady);
+
+ /** With reduced motion the light is still and changes are instant. */
+ void setReducedMotion(boolean reducedMotion);
+}
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/JackOLanternDrawable.java b/launcher/app/src/main/java/com/gathin/tvhome/JackOLanternDrawable.java
new file mode 100644
index 000000000..520a7fbb6
--- /dev/null
+++ b/launcher/app/src/main/java/com/gathin/tvhome/JackOLanternDrawable.java
@@ -0,0 +1,198 @@
+package com.gathin.tvhome;
+
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.ColorFilter;
+import android.graphics.Paint;
+import android.graphics.PixelFormat;
+import android.graphics.drawable.Drawable;
+import android.os.SystemClock;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import java.util.Random;
+
+/**
+ * A carved jack-o'-lantern for the network pill while the Halloween skin is on: its face glows while the TV is
+ * online and goes dark when the connection drops. The candle's brightness follows the signal level (1 to 4) and
+ * flickers a little while started; Ethernet burns steady. It is two pictures of the same pumpkin, dark and lit
+ * (from Microsoft's Fluent Emoji 3D, MIT), cross-faded, so it reads like the other skin's photo-real icons rather
+ * than a drawing. Frames run at about 15 fps only while the candle burns or fades; nothing is allocated per frame.
+ */
+public final class JackOLanternDrawable extends Drawable implements FestiveLamp {
+
+ private static final float BOX_DP = 24f;
+ private static final long FRAME_MS = 66, FADE_MS = 350;
+ /** How brightly the face glows at each level; index 0 is dark. */
+ private static final float[] LEVEL_GLOW = {0f, 0.55f, 0.72f, 0.88f, 1f};
+
+ private final float density;
+ private final Bitmap dark, lit;
+ private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
+ private final float[] noise = new float[64];
+ private final long epoch = SystemClock.uptimeMillis();
+
+ private int level = 4;
+ private boolean primed, running, steady, reduced;
+ private float glowFrom = 1f, glowTo = 1f;
+ private long fadeStart;
+ private int alpha = 255;
+
+ private final Runnable tick = new Runnable() {
+ @Override
+ public void run() {
+ invalidateSelf();
+ if (wantsFrames()) scheduleSelf(this, SystemClock.uptimeMillis() + FRAME_MS);
+ }
+ };
+
+ public JackOLanternDrawable(Resources res, float density) {
+ this.density = density;
+ dark = BitmapFactory.decodeResource(res, R.drawable.halloween_pumpkin_dark);
+ lit = BitmapFactory.decodeResource(res, R.drawable.halloween_pumpkin_lit);
+ Random rnd = new Random(0xC731L);
+ for (int i = 0; i < noise.length; i++) noise[i] = rnd.nextFloat();
+ }
+
+ @Override
+ public void setFlame(int newLevel) {
+ int lvl = Math.max(0, Math.min(4, newLevel));
+ long now = SystemClock.uptimeMillis();
+ if (!primed || reduced) {
+ primed = true;
+ level = lvl;
+ glowFrom = glowTo = LEVEL_GLOW[lvl];
+ kick();
+ return;
+ }
+ if (lvl == level) return;
+ glowFrom = glow(now);
+ glowTo = LEVEL_GLOW[lvl];
+ fadeStart = now;
+ level = lvl;
+ kick();
+ }
+
+ @Override
+ public void setSteady(boolean steady) {
+ if (this.steady == steady) return;
+ this.steady = steady;
+ invalidateSelf();
+ }
+
+ @Override
+ public void setReducedMotion(boolean reducedMotion) {
+ if (reduced == reducedMotion) return;
+ reduced = reducedMotion;
+ if (reduced) glowFrom = glowTo;
+ kick();
+ }
+
+ @Override
+ public void start() {
+ if (running) return;
+ running = true;
+ kick();
+ }
+
+ @Override
+ public void stop() {
+ if (!running) return;
+ running = false;
+ glowFrom = glowTo;
+ kick();
+ }
+
+ @Override
+ public boolean isRunning() {
+ return running;
+ }
+
+ @Override
+ public boolean setVisible(boolean visible, boolean restart) {
+ boolean changed = super.setVisible(visible, restart);
+ if (changed) kick();
+ return changed;
+ }
+
+ private boolean fading(long now) {
+ return glowFrom != glowTo && now - fadeStart < FADE_MS;
+ }
+
+ private boolean wantsFrames() {
+ return running && isVisible() && !reduced && (level > 0 || fading(SystemClock.uptimeMillis()));
+ }
+
+ private void kick() {
+ unscheduleSelf(tick);
+ if (wantsFrames()) scheduleSelf(tick, SystemClock.uptimeMillis() + FRAME_MS);
+ invalidateSelf();
+ }
+
+ /** The face's brightness now, easing from the last level to the new one. */
+ private float glow(long now) {
+ float p = Math.min(1f, Math.max(0f, (now - fadeStart) / (float) FADE_MS));
+ float e = 1f - (1f - p) * (1f - p);
+ return glowFrom + (glowTo - glowFrom) * e;
+ }
+
+ /** A candle's flicker: smooth noise around 1, a slow breath when steady, nothing when still. */
+ private float flicker(long now) {
+ if (!running || reduced || level == 0) return 1f;
+ float t = (now - epoch) / 1000f;
+ if (steady) return 0.97f + 0.03f * (float) Math.sin(t * 1.6f);
+ float x = t * 7f;
+ int i = (int) x;
+ float f = x - i;
+ float s = f * f * (3f - 2f * f);
+ float n = noise[i & 63] + (noise[(i + 1) & 63] - noise[i & 63]) * s;
+ return 0.84f + 0.16f * n;
+ }
+
+ @Override
+ public void draw(@NonNull Canvas canvas) {
+ long now = SystemClock.uptimeMillis();
+ paint.setAlpha(alpha);
+ canvas.drawBitmap(dark, null, getBounds(), paint);
+ float g = glow(now) * flicker(now);
+ if (g <= 0.01f) return;
+ paint.setAlpha(Math.round(alpha * Math.min(1f, g)));
+ canvas.drawBitmap(lit, null, getBounds(), paint);
+ }
+
+ @Override
+ public int getIntrinsicWidth() {
+ return Math.round(BOX_DP * density);
+ }
+
+ @Override
+ public int getIntrinsicHeight() {
+ return Math.round(BOX_DP * density);
+ }
+
+ @Override
+ public void setAlpha(int alpha) {
+ if (this.alpha == alpha) return;
+ this.alpha = alpha;
+ invalidateSelf();
+ }
+
+ @Override
+ public int getAlpha() {
+ return alpha;
+ }
+
+ @Override
+ public void setColorFilter(@Nullable ColorFilter filter) {
+ paint.setColorFilter(filter);
+ invalidateSelf();
+ }
+
+ @Override
+ public int getOpacity() {
+ return PixelFormat.TRANSLUCENT;
+ }
+}
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
index fd97c5427..a68495feb 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -252,7 +252,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
/** Festive skin from the theme (see Festival); applied while it is active today. */
private Festival festival = Festival.NONE;
private boolean festive;
- private DiyaDrawable diya;
+ /** The network pill's festive light: the diya, or the jack-o'-lantern for Halloween. */
+ private FestiveLamp lamp;
private BellDrawable bell;
private MarigoldDrawable marigold;
private int greetingColor;
@@ -411,7 +412,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
public void run() {
updateGreeting();
updatePanel();
- // The pill follows the network callbacks and each return to Home; only the diya's flame follows the
+ // The pill follows the network callbacks and each return to Home; only the festive light follows the
// signal level, so only it needs this minute's binder calls (about 7 ms on the UI thread).
if (festive) updateWifiLabel();
sky.update();
@@ -1058,8 +1059,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
sky.update();
wallpaperPlayer.start();
handler.postDelayed(minuteTick, MINUTE_MS);
- if (festive && diya != null) {
- diya.start();
+ if (festive && lamp != null) {
+ lamp.start();
LocalDate today = LocalDate.now();
if (!reducedMotion && !today.equals(lastPetalShower)) {
lastPetalShower = today;
@@ -1237,7 +1238,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
stopStats();
if (gameDay != null) gameDay.stop();
handler.removeCallbacks(turnTick);
- if (diya != null) diya.stop();
+ if (lamp != null) lamp.stop();
cancelPendingFocusScroll();
// Nothing of ours stays on screen over another app; an undecided prompt simply returns next time.
if (cardPrompt != null) cardPrompt.dismiss();
@@ -2776,7 +2777,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
String text = getString(R.string.wifi);
boolean vpn = false, online = false, validated = false;
int icon = R.drawable.ic_wifi;
- // The diya's flame: 0 is out (offline), 1 to 4 follow the Wi-Fi signal, Ethernet burns steady at 4.
+ // The festive light (diya flame or jack-o'-lantern candle): 0 is out (offline), 1 to 4 follow the Wi-Fi
+ // signal, Ethernet burns steady at 4.
int flame = 0;
boolean steady = false;
try {
@@ -2852,10 +2854,10 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
btnWifi.setContentDescription(btnWifi.getText());
btnWifi.setText(null);
}
- if (festive && diya != null) {
+ if (festive && lamp != null) {
if (online && flame == 0) flame = 3; // online some other way (cellular, USB tethering)
- diya.setSteady(steady);
- diya.setFlame(flame);
+ lamp.setSteady(steady);
+ lamp.setFlame(flame);
} else {
if (icon != wifiIcon) {
wifiIcon = icon;
@@ -2905,15 +2907,33 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
/**
* Swaps the pill icons for the festival's: a bell for Inputs that swings when focused, a diya for the
- * network whose flame follows the connection, and a marigold for Settings that turns when focused.
+ * network whose flame follows the connection, and a marigold for Settings that turns when focused. Halloween
+ * has its own: a bat for Inputs that flaps, a jack-o'-lantern whose face glows while online, and a ghost for
+ * Settings that floats up.
*/
private void applyFestiveSkin(TextView inputs, TextView settings) {
+ if (festival.isHalloween()) {
+ SpookyIconDrawable bat = new SpookyIconDrawable(getResources(), density, SpookyIconDrawable.BAT);
+ SpookyIconDrawable ghost = new SpookyIconDrawable(getResources(), density, SpookyIconDrawable.GHOST);
+ JackOLanternDrawable pumpkin = new JackOLanternDrawable(getResources(), density);
+ bat.setReducedMotion(reducedMotion);
+ ghost.setReducedMotion(reducedMotion);
+ pumpkin.setReducedMotion(reducedMotion);
+ lamp = pumpkin;
+ setFestiveIcon(inputs, bat);
+ setFestiveIcon(btnWifi, pumpkin);
+ setFestiveIcon(settings, ghost);
+ addFocusAction(inputs, bat::nudge);
+ addFocusAction(settings, ghost::nudge);
+ return;
+ }
bell = new BellDrawable(density);
marigold = new MarigoldDrawable(density);
- diya = new DiyaDrawable(density);
+ DiyaDrawable diya = new DiyaDrawable(density);
bell.setReducedMotion(reducedMotion);
marigold.setReducedMotion(reducedMotion);
diya.setReducedMotion(reducedMotion);
+ lamp = diya;
setFestiveIcon(inputs, bell);
setFestiveIcon(btnWifi, diya);
setFestiveIcon(settings, marigold);
@@ -2938,6 +2958,13 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private void playPetalShower() {
if (isFinishing() || isDestroyed()) return;
+ if (festival.isHalloween()) {
+ BatFlightView bats = new BatFlightView(this);
+ root.addView(bats, new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+ bats.play(16, 2800, () -> root.removeView(bats));
+ return;
+ }
PetalShowerView shower = new PetalShowerView(this);
root.addView(shower, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/SpookyIconDrawable.java b/launcher/app/src/main/java/com/gathin/tvhome/SpookyIconDrawable.java
new file mode 100644
index 000000000..3e01a35a7
--- /dev/null
+++ b/launcher/app/src/main/java/com/gathin/tvhome/SpookyIconDrawable.java
@@ -0,0 +1,137 @@
+package com.gathin.tvhome;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.ValueAnimator;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.ColorFilter;
+import android.graphics.Paint;
+import android.graphics.PixelFormat;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.view.animation.LinearInterpolator;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+/**
+ * A Halloween pill icon from a picture (Microsoft's Fluent Emoji 3D, MIT): a bat for Inputs that flaps its wings
+ * twice when focused, or a ghost for Settings that drifts up and settles. The motion is a short scale or
+ * offset of the same picture, played once per {@link #nudge()}; reduced motion leaves it still.
+ */
+public final class SpookyIconDrawable extends Drawable {
+
+ static final int BAT = 0, GHOST = 1;
+
+ private static final float BOX_DP = 24f;
+ private static final long BAT_MS = 520, GHOST_MS = 900;
+
+ private final int kind;
+ private final float density;
+ private final Bitmap bitmap;
+ private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
+ private final Rect dst = new Rect();
+ private final ValueAnimator animator;
+ private float t = -1f;
+ private boolean reduced;
+ private int alpha = 255;
+
+ public SpookyIconDrawable(Resources res, float density, int kind) {
+ this.kind = kind;
+ this.density = density;
+ bitmap = BitmapFactory.decodeResource(res,
+ kind == BAT ? R.drawable.halloween_bat : R.drawable.halloween_ghost);
+ animator = ValueAnimator.ofFloat(0f, 1f);
+ animator.setDuration(kind == BAT ? BAT_MS : GHOST_MS);
+ animator.setInterpolator(new LinearInterpolator());
+ animator.addUpdateListener(a -> {
+ t = (float) a.getAnimatedValue();
+ invalidateSelf();
+ });
+ animator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator a) {
+ t = -1f;
+ invalidateSelf();
+ }
+ });
+ }
+
+ /** The focus motion: two wing beats for the bat, a float up and back for the ghost. */
+ public void nudge() {
+ if (reduced) return;
+ animator.cancel();
+ animator.start();
+ }
+
+ /** With reduced motion {@link #nudge()} does nothing and a motion in progress stops at rest. */
+ public void setReducedMotion(boolean reducedMotion) {
+ reduced = reducedMotion;
+ if (reduced && animator.isRunning()) animator.cancel();
+ }
+
+ @Override
+ public void draw(@NonNull Canvas canvas) {
+ Rect b = getBounds();
+ float sx = 1f, sy = 1f, dy = 0f, rot = 0f;
+ if (t >= 0f) {
+ if (kind == BAT) {
+ // two beats: the wings fold (the picture squeezes vertically) and open again
+ float beat = (float) Math.sin(t * 2 * Math.PI * 2);
+ sy = 1f - 0.28f * Math.abs(beat);
+ sx = 1f + 0.06f * Math.abs(beat);
+ dy = -1.5f * density * (float) Math.sin(t * Math.PI);
+ } else {
+ // drifts up about 3 dp, tilting slightly, then sinks back
+ float up = (float) Math.sin(t * Math.PI);
+ dy = -3f * density * up;
+ rot = 6f * (float) Math.sin(t * 2 * Math.PI) * (1f - t);
+ }
+ }
+ int save = canvas.save();
+ canvas.translate(b.exactCenterX(), b.exactCenterY() + dy);
+ canvas.rotate(rot);
+ canvas.scale(sx, sy);
+ int hw = b.width() / 2, hh = b.height() / 2;
+ dst.set(-hw, -hh, b.width() - hw, b.height() - hh);
+ paint.setAlpha(alpha);
+ canvas.drawBitmap(bitmap, null, dst, paint);
+ canvas.restoreToCount(save);
+ }
+
+ @Override
+ public int getIntrinsicWidth() {
+ return Math.round(BOX_DP * density);
+ }
+
+ @Override
+ public int getIntrinsicHeight() {
+ return Math.round(BOX_DP * density);
+ }
+
+ @Override
+ public void setAlpha(int alpha) {
+ if (this.alpha == alpha) return;
+ this.alpha = alpha;
+ invalidateSelf();
+ }
+
+ @Override
+ public int getAlpha() {
+ return alpha;
+ }
+
+ @Override
+ public void setColorFilter(@Nullable ColorFilter filter) {
+ paint.setColorFilter(filter);
+ invalidateSelf();
+ }
+
+ @Override
+ public int getOpacity() {
+ return PixelFormat.TRANSLUCENT;
+ }
+}
diff --git a/launcher/app/src/main/res/drawable-nodpi/halloween_bat.webp b/launcher/app/src/main/res/drawable-nodpi/halloween_bat.webp
new file mode 100644
index 000000000..3e6f0884c
Binary files /dev/null and b/launcher/app/src/main/res/drawable-nodpi/halloween_bat.webp differ
diff --git a/launcher/app/src/main/res/drawable-nodpi/halloween_ghost.webp b/launcher/app/src/main/res/drawable-nodpi/halloween_ghost.webp
new file mode 100644
index 000000000..96affed57
Binary files /dev/null and b/launcher/app/src/main/res/drawable-nodpi/halloween_ghost.webp differ
diff --git a/launcher/app/src/main/res/drawable-nodpi/halloween_pumpkin_dark.webp b/launcher/app/src/main/res/drawable-nodpi/halloween_pumpkin_dark.webp
new file mode 100644
index 000000000..ae653323e
Binary files /dev/null and b/launcher/app/src/main/res/drawable-nodpi/halloween_pumpkin_dark.webp differ
diff --git a/launcher/app/src/main/res/drawable-nodpi/halloween_pumpkin_lit.webp b/launcher/app/src/main/res/drawable-nodpi/halloween_pumpkin_lit.webp
new file mode 100644
index 000000000..d1ae6e3b8
Binary files /dev/null and b/launcher/app/src/main/res/drawable-nodpi/halloween_pumpkin_lit.webp differ
diff --git a/launcher/app/src/main/res/values-da/strings.xml b/launcher/app/src/main/res/values-da/strings.xml
index 05593e6c8..001c4f6c7 100644
--- a/launcher/app/src/main/res/values-da/strings.xml
+++ b/launcher/app/src/main/res/values-da/strings.xml
@@ -18,6 +18,7 @@
<string name="good_night">God nat</string>
<string name="festival_dussehra_greeting">Glædelig Dussehra</string>
<string name="festival_diwali_greeting">Glædelig Diwali</string>
+ <string name="festival_halloween_greeting">Glædelig halloween</string>
<string name="ethernet">Ethernet</string>
<string name="offline">Offline</string>
<string name="not_available">Ikke tilgængelig på dette TV</string>
diff --git a/launcher/app/src/main/res/values-es/strings.xml b/launcher/app/src/main/res/values-es/strings.xml
index 2530c2acd..c3c81c31c 100644
--- a/launcher/app/src/main/res/values-es/strings.xml
+++ b/launcher/app/src/main/res/values-es/strings.xml
@@ -17,6 +17,7 @@
<string name="good_night">Buenas noches</string>
<string name="festival_dussehra_greeting">Feliz Dussehra</string>
<string name="festival_diwali_greeting">Feliz Diwali</string>
+ <string name="festival_halloween_greeting">Feliz Halloween</string>
<string name="ethernet">Ethernet</string>
<string name="offline">Sin conexión</string>
<string name="not_available">No disponible en este TV</string>
diff --git a/launcher/app/src/main/res/values-it/strings.xml b/launcher/app/src/main/res/values-it/strings.xml
index 5fc97d499..2d95634df 100644
--- a/launcher/app/src/main/res/values-it/strings.xml
+++ b/launcher/app/src/main/res/values-it/strings.xml
@@ -18,6 +18,7 @@
<string name="good_night">Buonanotte</string>
<string name="festival_dussehra_greeting">Buon Dussehra</string>
<string name="festival_diwali_greeting">Buon Diwali</string>
+ <string name="festival_halloween_greeting">Buon Halloween</string>
<string name="ethernet">Ethernet</string>
<string name="offline">Offline</string>
<string name="not_available">Non disponibile su questa TV</string>
diff --git a/launcher/app/src/main/res/values-iw/strings.xml b/launcher/app/src/main/res/values-iw/strings.xml
index a346a4e7f..6698661de 100644
--- a/launcher/app/src/main/res/values-iw/strings.xml
+++ b/launcher/app/src/main/res/values-iw/strings.xml
@@ -18,6 +18,7 @@
<string name="good_night">לילה טוב</string>
<string name="festival_dussehra_greeting">חג דוסרה שמח</string>
<string name="festival_diwali_greeting">חג דיוואלי שמח</string>
+ <string name="festival_halloween_greeting">ליל כל הקדושים שמח</string>
<string name="ethernet">רשת קווית</string>
<string name="offline">אין חיבור לרשת</string>
<string name="not_available">לא זמין בטלוויזיה זו</string>
diff --git a/launcher/app/src/main/res/values-ko/strings.xml b/launcher/app/src/main/res/values-ko/strings.xml
index a2336606e..466b9df9d 100644
--- a/launcher/app/src/main/res/values-ko/strings.xml
+++ b/launcher/app/src/main/res/values-ko/strings.xml
@@ -17,6 +17,7 @@
<string name="good_night">편안한 밤 되세요</string>
<string name="festival_dussehra_greeting">행복한 두세라 되세요</string>
<string name="festival_diwali_greeting">행복한 디왈리 되세요</string>
+ <string name="festival_halloween_greeting">해피 할로윈</string>
<string name="ethernet">이더넷</string>
<string name="offline">오프라인</string>
<string name="not_available">이 TV에서 사용할 수 없음</string>
diff --git a/launcher/app/src/main/res/values-pt/strings.xml b/launcher/app/src/main/res/values-pt/strings.xml
index 669ee78b2..06f0db1d5 100644
--- a/launcher/app/src/main/res/values-pt/strings.xml
+++ b/launcher/app/src/main/res/values-pt/strings.xml
@@ -17,6 +17,7 @@
<string name="good_night">Boa noite</string>
<string name="festival_dussehra_greeting">Feliz Dussehra</string>
<string name="festival_diwali_greeting">Feliz Diwali</string>
+ <string name="festival_halloween_greeting">Feliz Halloween</string>
<string name="shamsi_month_farvardin">Farvardin</string>
<string name="shamsi_month_ordibehesht">Ordibehesht</string>
<string name="shamsi_month_khordad">Khordad</string>
diff --git a/launcher/app/src/main/res/values-ru/strings.xml b/launcher/app/src/main/res/values-ru/strings.xml
index adadf9adc..28ef869c3 100644
--- a/launcher/app/src/main/res/values-ru/strings.xml
+++ b/launcher/app/src/main/res/values-ru/strings.xml
@@ -17,6 +17,7 @@
<string name="good_night">Доброй ночи</string>
<string name="festival_dussehra_greeting">С праздником Дашахра!</string>
<string name="festival_diwali_greeting">С праздником Дивали!</string>
+ <string name="festival_halloween_greeting">Счастливого Хэллоуина!</string>
<string name="ethernet">Ethernet</string>
<string name="offline">Нет сети</string>
<string name="not_available">Недоступно на этом телевизоре</string>
diff --git a/launcher/app/src/main/res/values-sv/strings.xml b/launcher/app/src/main/res/values-sv/strings.xml
index 7dc452756..9595be03c 100644
--- a/launcher/app/src/main/res/values-sv/strings.xml
+++ b/launcher/app/src/main/res/values-sv/strings.xml
@@ -18,6 +18,7 @@
<string name="good_night">God natt</string>
<string name="festival_dussehra_greeting">Glad Dussehra</string>
<string name="festival_diwali_greeting">Glad Diwali</string>
+ <string name="festival_halloween_greeting">Glad halloween</string>
<string name="ethernet">Ethernet</string>
<string name="offline">Frånkopplad</string>
<string name="not_available">Inte tillgängligt på den här TV:n</string>
diff --git a/launcher/app/src/main/res/values-uk/strings.xml b/launcher/app/src/main/res/values-uk/strings.xml
index 31e5a3862..a05ab6fff 100644
--- a/launcher/app/src/main/res/values-uk/strings.xml
+++ b/launcher/app/src/main/res/values-uk/strings.xml
@@ -17,6 +17,7 @@
<string name="good_night">Доброї ночі</string>
<string name="festival_dussehra_greeting">Зі святом Дашахра!</string>
<string name="festival_diwali_greeting">Зі святом Дівалі!</string>
+ <string name="festival_halloween_greeting">Щасливого Гелловіну!</string>
<string name="ethernet">Ethernet</string>
<string name="offline">Не в мережі</string>
<string name="not_available">Недоступно на цьому телевізорі</string>
diff --git a/launcher/app/src/main/res/values-vi/strings.xml b/launcher/app/src/main/res/values-vi/strings.xml
index 1546901db..07cc126b3 100644
--- a/launcher/app/src/main/res/values-vi/strings.xml
+++ b/launcher/app/src/main/res/values-vi/strings.xml
@@ -79,6 +79,7 @@
<string name="dock_edit_pick_place">Chọn vị trí trên dock cho ứng dụng này rồi nhấn OK. Nhấn Quay lại để hủy.</string>
<string name="festival_dussehra_greeting">Chúc mừng lễ Dussehra</string>
<string name="festival_diwali_greeting">Chúc mừng lễ Diwali</string>
+ <string name="festival_halloween_greeting">Chúc mừng Halloween</string>
<string name="stats_memory">Bộ nhớ %1$d / %2$d MB</string>
<string name="stats_storage">Còn trống %1$s</string>
<string name="rows_below_dock_label">Số hàng dưới dock</string>
diff --git a/launcher/app/src/main/res/values-zh-rCN/strings.xml b/launcher/app/src/main/res/values-zh-rCN/strings.xml
index 2444a50ef..eb2ec26ff 100644
--- a/launcher/app/src/main/res/values-zh-rCN/strings.xml
+++ b/launcher/app/src/main/res/values-zh-rCN/strings.xml
@@ -44,6 +44,7 @@
<string name="good_night">晚安</string>
<string name="festival_dussehra_greeting">十胜节快乐</string>
<string name="festival_diwali_greeting">排灯节快乐</string>
+ <string name="festival_halloween_greeting">万圣节快乐</string>
<string name="ethernet">有线网络</string>
<string name="offline">未连接网络</string>
<string name="not_available">此电视不支持该功能</string>
diff --git a/launcher/app/src/main/res/values/strings.xml b/launcher/app/src/main/res/values/strings.xml
index e65576620..b340641b7 100644
--- a/launcher/app/src/main/res/values/strings.xml
+++ b/launcher/app/src/main/res/values/strings.xml
@@ -18,6 +18,7 @@
<string name="good_night">Good night</string>
<string name="festival_dussehra_greeting">Happy Dussehra</string>
<string name="festival_diwali_greeting">Happy Diwali</string>
+ <string name="festival_halloween_greeting">Happy Halloween</string>
<string name="ethernet">Ethernet</string>
<string name="offline">Offline</string>
<string name="not_available">Not available on this TV</string>
diff --git a/launcher/app/src/test/java/com/gathin/tvhome/FestivalTest.java b/launcher/app/src/test/java/com/gathin/tvhome/FestivalTest.java
index 8be572361..497748f69 100644
--- a/launcher/app/src/test/java/com/gathin/tvhome/FestivalTest.java
+++ b/launcher/app/src/test/java/com/gathin/tvhome/FestivalTest.java
@@ -50,4 +50,22 @@ public class FestivalTest {
assertEquals(0xFF102030, Festival.parse("dussehra", "", "", "#102030").accentColor());
assertEquals(Festival.DEFAULT_ACCENT, Festival.parse("dussehra", "", "", "gold").accentColor());
}
+
+ @Test
+ public void halloweenHasItsOwnSkinAndPumpkinAccent() {
+ Festival f = Festival.parse("Halloween", "2026-11-01", "", "");
+ assertTrue(f.isHalloween());
+ assertTrue(f.active(LocalDate.of(2026, 10, 31)));
+ assertTrue(f.active(LocalDate.of(2026, 11, 1)));
+ assertFalse(f.active(LocalDate.of(2026, 11, 2)));
+ assertEquals(Festival.PUMPKIN, f.accentColor());
+ assertEquals(0xFFAA5500, Festival.parse("halloween", "", "", "#AA5500").accentColor());
+ }
+
+ @Test
+ public void otherFestivalsKeepTheDiyaSkin() {
+ assertFalse(Festival.parse("dussehra", "", "", "").isHalloween());
+ assertFalse(Festival.parse("onam", "", "", "").isHalloween());
+ assertFalse(Festival.NONE.isHalloween());
+ }
}