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
launcher: optional time-of-day sky backdrop (off by default)
ottoben1996f9f04ecd97d8
diff --git a/docs/sky-sunset.jpg b/docs/sky-sunset.jpgnew file mode 100644index 000000000..009c960f2Binary files /dev/null and b/docs/sky-sunset.jpg differdiff --git a/docs/sky.md b/docs/sky.mdnew file mode 100644index 000000000..19dc514f1--- /dev/null+++ b/docs/sky.md@@ -0,0 +1,39 @@+# Sky++An optional backdrop that follows the clock: night blues until dawn, a soft blue day, then a warm+horizon that peaks just before eight in the evening. It is off in the built-in configuration, so a+launcher built from this repository behaves exactly like before until a theme turns it on.++```json+{ "sky_intensity": 60 }+```++++Push that as a theme's `config.json` and restart Home:++```bash+TV_HOST=192.168.1.50 tools/theme.sh themes/your-theme+```++## What it draws++A full-screen gradient in three bands — top, middle, bottom — with a soft warm glow near the horizon+whose horizontal position follows the sun: left at sunrise, right at sunset. `sky_intensity` is its+opacity, 0 to 100; the colours themselves are interpolated between a handful of anchors through the+day, which is what makes it drift instead of switching at fixed hours.++It sits behind everything, over the wallpaper when there is one, and the palette was chosen dark on+purpose: the white clock, the greeting, the hero name and the dock band all keep their contrast at+the default 60.++## Cost++`Sky` is pure maths — no Android types, no clock of its own; the caller passes the minutes since+midnight, which is why the palette is unit-tested on the JVM. `SkyView` renders one 480×270 bitmap+and redraws it once a minute, from the same minute tick that updates the clock. Nothing is animated+and nothing is requested: the backdrop is the only change, and a TV with 1 GB of RAM has nothing to+keep up with.++Turning the key off restores the plain background (or the theme's `wallpaper`/`background_color`)+on the next Home start.diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Config.java b/launcher/app/src/main/java/com/gathin/tvhome/Config.javaindex ab95d9611..e70d2617d 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java@@ -48,6 +48,8 @@ final class Config {final boolean showHomeSettingsShortcut;/** Background colour behind everything, #RRGGBB; black unless a theme says otherwise. */final int backgroundColor;+ /** Time-of-day backdrop, 0 to 100 (config.xml, sky_intensity); 0 keeps the plain background. */+ final int skyIntensity;/** Full-screen picture behind the launcher, or null for the plain colour. */final File wallpaper;/** Whether the overlay file was present and parsed. */@@ -57,7 +59,7 @@ final class Config {String sourcePanelService, String sourcePanelAction, String inputAction,int columns, int rowsBelowDock,boolean shamsiDate, boolean moduleCards, boolean reducedMotion, String vpnApp,- boolean showHomeSettingsShortcut, int backgroundColor,+ boolean showHomeSettingsShortcut, int backgroundColor, int skyIntensity,File wallpaper, boolean overlayApplied) {this.dockApps = Collections.unmodifiableList(dockApps);this.hiddenApps = Collections.unmodifiableList(hiddenApps);@@ -74,6 +76,7 @@ final class Config {this.vpnApp = vpnApp;this.showHomeSettingsShortcut = showHomeSettingsShortcut;this.backgroundColor = backgroundColor;+ this.skyIntensity = skyIntensity;this.wallpaper = wallpaper;this.overlayApplied = overlayApplied;}@@ -100,6 +103,7 @@ final class Config {String vpn = res.getString(R.string.vpn_app).trim();boolean homeSettings = res.getBoolean(R.bool.show_home_settings_shortcut);int background = 0xFF000000;+ int skyIntensity = res.getInteger(R.integer.sky_intensity);boolean applied = false;File dir = dir(ctx);@@ -122,6 +126,7 @@ final class Config {vpn = string(json, "vpn_app", vpn);homeSettings = bool(json, "show_home_settings_shortcut", homeSettings);background = color(json, "background_color", background);+ skyIntensity = integer(json, "sky_intensity", skyIntensity, 0, 100);}File wallpaper = dir != null ? new File(dir, WALLPAPER_NAME) : null;if (wallpaper != null && !(wallpaper.isFile() && wallpaper.length() > 0)) wallpaper = null;@@ -130,7 +135,8 @@ final class Config {return new Config(dock, hidden, liveTv, liveTvAction, panelService, panelAction, inputAction,Math.max(1, columns), Math.max(0, rowsBelow), shamsi, moduleCards, reducedMotion,- vpn, homeSettings, background, wallpaper, applied);+ vpn, homeSettings, background, Math.max(0, Math.min(100, skyIntensity)),+ wallpaper, applied);}/** Reads and parses the overlay; any problem means "no overlay", never a crash on the home screen. */diff --git a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.javaindex 499018535..f813631ab 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java@@ -95,6 +95,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {private TextView btnWifi;private TextView shamsiDate;private boolean shamsi;+ /** Optional time-of-day backdrop (config.xml, sky_intensity); 0 keeps it hidden. */+ private SkyView sky;private String vpnApp;private SpringAnimation springX, springY;private float glassTargetX, glassTargetY;@@ -175,6 +177,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {public void run() {updateGreeting();updateWifiLabel();+ sky.update();handler.postDelayed(this, MINUTE_MS);}};@@ -197,6 +200,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {root = findViewById(R.id.root);root.setBackgroundColor(cfg.backgroundColor);if (cfg.wallpaper != null) showWallpaper(cfg.wallpaper);+ sky = findViewById(R.id.sky);+ sky.setIntensity(cfg.skyIntensity);glass = findViewById(R.id.glass);ambient = findViewById(R.id.ambient);heroName = findViewById(R.id.heroName);@@ -390,6 +395,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {updateGreeting();updateWifiLabel();updateInputsButton();+ sky.update();handler.postDelayed(minuteTick, MINUTE_MS);}diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Sky.java b/launcher/app/src/main/java/com/gathin/tvhome/Sky.javanew file mode 100644index 000000000..04d789d8f--- /dev/null+++ b/launcher/app/src/main/java/com/gathin/tvhome/Sky.java@@ -0,0 +1,119 @@+package com.gathin.tvhome;++/**+ * Time-of-day sky palette for the optional "sunset" backdrop (config.xml, sky_intensity).+ *+ * Pure maths, no Android types and no clock of its own: the caller passes minutes since midnight,+ * so the palette can be tested on the JVM. The colours are interpolated between a handful of+ * anchor points through the day, which is what makes the backdrop drift from night to dawn to+ * sunset instead of switching at fixed hours. Every colour stays dark enough for the white+ * text, the hero name and the dock band to keep their contrast.+ */+final class Sky {++ /** One anchor: a minute of the day and the values the palette takes exactly there. */+ static final class Stop {+ final int minute;+ final int top;+ final int mid;+ final int bottom;+ /** Alpha of the sun/moon glow near the horizon, 0 to 255. */+ final int sun;+ /** Horizontal position of the glow, 0 = left edge, 1 = right edge. */+ final float sunX;++ Stop(int minute, int top, int mid, int bottom, int sun, float sunX) {+ this.minute = minute;+ this.top = top;+ this.mid = mid;+ this.bottom = bottom;+ this.sun = sun;+ this.sunX = sunX;+ }+ }++ /** The palette at one instant: the three gradient colours plus the glow. */+ static final class Palette {+ final int top;+ final int mid;+ final int bottom;+ final int sun;+ final float sunX;++ Palette(int top, int mid, int bottom, int sun, float sunX) {+ this.top = top;+ this.mid = mid;+ this.bottom = bottom;+ this.sun = sun;+ this.sunX = sunX;+ }+ }++ private static final int NIGHT_TOP = 0xFF04060E;+ private static final int NIGHT_MID = 0xFF070C1A;+ private static final int NIGHT_BOTTOM = 0xFF0B1326;++ // Anchors were picked around a temperate evening: full night until half past five, dawn before+ // seven, the warmest glow between seven in the evening and a quarter to eight.+ private static final Stop[] STOPS = {+ new Stop(0, NIGHT_TOP, NIGHT_MID, NIGHT_BOTTOM, 0, 0.30f),+ new Stop(320, NIGHT_TOP, NIGHT_MID, NIGHT_BOTTOM, 0, 0.30f),+ new Stop(390, 0xFF160F2E, 0xFF3B2352, 0xFF8A4A6B, 100, 0.24f),+ new Stop(450, 0xFF12203F, 0xFF5C3A63, 0xFFD3674F, 160, 0.30f),+ new Stop(570, 0xFF0E1A33, 0xFF1F3557, 0xFF43648B, 90, 0.38f),+ new Stop(780, 0xFF0B1524, 0xFF17304F, 0xFF31587F, 60, 0.50f),+ new Stop(1020, 0xFF0D1526, 0xFF20395C, 0xFF4C5470, 90, 0.62f),+ new Stop(1140, 0xFF1B1030, 0xFF6C2E52, 0xFFE2704A, 190, 0.76f),+ new Stop(1185, 0xFF140C27, 0xFF4A2049, 0xFFA54A5C, 130, 0.82f),+ new Stop(1260, 0xFF0A0A1C, 0xFF191230, 0xFF3A1F49, 60, 0.86f),+ new Stop(1350, NIGHT_TOP, NIGHT_MID, NIGHT_BOTTOM, 0, 0.30f),+ new Stop(1440, NIGHT_TOP, NIGHT_MID, NIGHT_BOTTOM, 0, 0.30f),+ };++ private Sky() {+ }++ /** The palette at {@code minuteOfDay}, clamped to a day. */+ static Palette at(int minuteOfDay) {+ int m = Math.max(0, Math.min(1440, minuteOfDay));+ Stop a = STOPS[0];+ Stop b = STOPS[STOPS.length - 1];+ for (int i = 0; i < STOPS.length - 1; i++) {+ if (m >= STOPS[i].minute && m <= STOPS[i + 1].minute) {+ a = STOPS[i];+ b = STOPS[i + 1];+ break;+ }+ }+ float t = b.minute == a.minute ? 0f : (m - a.minute) / (float) (b.minute - a.minute);+ return new Palette(+ lerpColor(a.top, b.top, t),+ lerpColor(a.mid, b.mid, t),+ lerpColor(a.bottom, b.bottom, t),+ lerp(a.sun, b.sun, t),+ lerp(a.sunX, b.sunX, t));+ }++ /** Minute of day, 0 to 1439, of a wall clock time. */+ static int minuteOfDay(int hour, int minute) {+ return Math.max(0, Math.min(23, hour)) * 60 + Math.max(0, Math.min(59, minute));+ }++ /** Blends two opaque ARGB colours channel by channel; {@code t} is 0 to 1. */+ static int lerpColor(int from, int to, float t) {+ float f = Math.max(0f, Math.min(1f, t));+ int a = Math.round(((from >>> 24) & 0xFF) + (((to >>> 24) & 0xFF) - ((from >>> 24) & 0xFF)) * f);+ int r = Math.round(((from >> 16) & 0xFF) + (((to >> 16) & 0xFF) - ((from >> 16) & 0xFF)) * f);+ int g = Math.round(((from >> 8) & 0xFF) + (((to >> 8) & 0xFF) - ((from >> 8) & 0xFF)) * f);+ int b = Math.round((from & 0xFF) + ((to & 0xFF) - (from & 0xFF)) * f);+ return (a << 24) | (r << 16) | (g << 8) | b;+ }++ private static int lerp(int from, int to, float t) {+ return Math.round(from + (to - from) * Math.max(0f, Math.min(1f, t)));+ }++ private static float lerp(float from, float to, float t) {+ return from + (to - from) * Math.max(0f, Math.min(1f, t));+ }+}diff --git a/launcher/app/src/main/java/com/gathin/tvhome/SkyView.java b/launcher/app/src/main/java/com/gathin/tvhome/SkyView.javanew file mode 100644index 000000000..19ea27a7a--- /dev/null+++ b/launcher/app/src/main/java/com/gathin/tvhome/SkyView.java@@ -0,0 +1,98 @@+package com.gathin.tvhome;++import android.content.Context;+import android.graphics.Bitmap;+import android.graphics.Canvas;+import android.graphics.LinearGradient;+import android.graphics.Paint;+import android.graphics.RadialGradient;+import android.graphics.Shader;+import android.graphics.drawable.BitmapDrawable;+import android.util.AttributeSet;+import android.view.Gravity;+import android.view.View;++import androidx.annotation.Nullable;++import java.util.Calendar;++/**+ * A full-screen gradient that follows the clock: night blues, a warm horizon at sunset, a soft+ * glow that travels with the sun. Off by default (config.xml, sky_intensity = 0); a theme turns+ * it on with {@code "sky_intensity": 60}.+ *+ * Like the ambient glow, the backdrop is one small bitmap (480x270) stretched over the screen:+ * a gradient repainted at full resolution every minute is exactly the CPU cost the ambient glow+ * was rewritten to avoid on weak GPUs. It is redrawn once a minute and never animated, so the+ * cost is a single full-screen draw per minute.+ */+public class SkyView extends View {++ private static final int TEX_W = 480;+ private static final int TEX_H = 270;++ /** Opacity of the whole backdrop, 0 to 255, from sky_intensity. */+ private int intensity;+ private int lastMinute = -1;+ private Bitmap texture;+ private BitmapDrawable drawable;++ public SkyView(Context context, @Nullable AttributeSet attrs) {+ super(context, attrs);+ }++ /** {@code percent} of sky_intensity: 0 hides the backdrop, 100 covers the wallpaper. */+ public void setIntensity(int percent) {+ intensity = Math.max(0, Math.min(100, percent));+ setAlpha(intensity / 100f);+ setVisibility(intensity == 0 ? GONE : VISIBLE);+ if (intensity > 0) render(true);+ }++ /** Picks up a new time of day; cheap and safe to call every minute. */+ public void update() {+ if (intensity == 0 || getVisibility() != VISIBLE) return;+ render(false);+ }++ @Override+ protected void onAttachedToWindow() {+ super.onAttachedToWindow();+ if (intensity > 0) render(true);+ }++ private void render(boolean force) {+ Calendar now = Calendar.getInstance();+ int minute = Sky.minuteOfDay(now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE));+ if (!force && minute == lastMinute) return;+ lastMinute = minute;++ Sky.Palette sky = Sky.at(minute);+ if (texture == null) texture = Bitmap.createBitmap(TEX_W, TEX_H, Bitmap.Config.ARGB_8888);+ Canvas canvas = new Canvas(texture);+ canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR);++ Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);+ paint.setShader(new LinearGradient(0f, 0f, 0f, TEX_H,+ new int[]{sky.top, sky.mid, sky.bottom},+ new float[]{0f, 0.55f, 1f}, Shader.TileMode.CLAMP));+ canvas.drawRect(0f, 0f, TEX_W, TEX_H, paint);++ if (sky.sun > 0) {+ // A warm core low on the horizon, where the sun (or its afterglow) sits.+ int warm = Sky.lerpColor(sky.bottom, 0xFFFFD9A0, 0.65f);+ paint.setShader(new RadialGradient(+ sky.sunX * TEX_W, TEX_H * 0.94f, TEX_W * 0.42f,+ new int[]{(sky.sun << 24) | (warm & 0x00FFFFFF), warm & 0x00FFFFFF},+ new float[]{0f, 1f}, Shader.TileMode.CLAMP));+ canvas.drawRect(0f, 0f, TEX_W, TEX_H, paint);+ }++ if (drawable == null) {+ drawable = new BitmapDrawable(getResources(), texture);+ drawable.setGravity(Gravity.FILL);+ setBackground(drawable);+ }+ invalidate();+ }+}diff --git a/launcher/app/src/main/res/layout/activity_main.xml b/launcher/app/src/main/res/layout/activity_main.xmlindex 91346acf5..590b81c39 100644--- a/launcher/app/src/main/res/layout/activity_main.xml+++ b/launcher/app/src/main/res/layout/activity_main.xml@@ -5,6 +5,13 @@android:layout_height="match_parent"android:background="#FF000000">+ <!-- Time-of-day backdrop, drawn once a minute (config.xml sky_intensity; 0 keeps it hidden). -->+ <com.gathin.tvhome.SkyView+ android:id="@+id/sky"+ android:layout_width="match_parent"+ android:layout_height="match_parent"+ android:importantForAccessibility="no" />+<!-- Ambient glow in the colour of the focused dock app. --><Viewandroid:id="@+id/ambient"diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xmlindex c0dc9181d..833f3d5ab 100644--- a/launcher/app/src/main/res/values/config.xml+++ b/launcher/app/src/main/res/values/config.xml@@ -74,4 +74,10 @@tiles that zoom without overshoot, shorter fades and no tile entrance when Home comes back. Set ithere or with "reduced_motion": true in a theme's config.json; false keeps the normal motion. --><bool name="reduced_motion">false</bool>++ <!-- Time-of-day backdrop behind everything: a dark gradient that follows the clock, with a warm+ horizon glow around sunrise and sunset. 0 keeps the plain background (the default); 1 to 100+ sets its opacity. Around 60 reads clearly without hiding a wallpaper. Can also be set with+ "sky_intensity": 60 in a theme's config.json. -->+ <integer name="sky_intensity">0</integer></resources>diff --git a/launcher/app/src/test/java/com/gathin/tvhome/SkyTest.java b/launcher/app/src/test/java/com/gathin/tvhome/SkyTest.javanew file mode 100644index 000000000..9f7e99ca4--- /dev/null+++ b/launcher/app/src/test/java/com/gathin/tvhome/SkyTest.java@@ -0,0 +1,68 @@+package com.gathin.tvhome;++import org.junit.Test;++import static org.junit.Assert.assertEquals;+import static org.junit.Assert.assertNotEquals;+import static org.junit.Assert.assertTrue;++/** Plain JVM tests for the sunset palette: anchors, interpolation and clamping. */+public class SkyTest {++ @Test+ public void nightLooksTheSameAtBothEndsOfTheDay() {+ Sky.Palette first = Sky.at(0);+ Sky.Palette last = Sky.at(1439);+ assertEquals(first.top, last.top);+ assertEquals(first.mid, last.mid);+ assertEquals(first.bottom, last.bottom);+ assertEquals(0, last.sun);+ }++ @Test+ public void glowPeaksAtSunriseAndSunset() {+ assertTrue(Sky.at(450).sun > Sky.at(780).sun); // 07:30 sunrise vs 13:00 day+ assertTrue(Sky.at(1140).sun > Sky.at(1260).sun); // 19:00 sunset vs 21:00 dusk+ assertTrue(Sky.at(1140).sun > Sky.at(450).sun); // the evening is the warmest moment+ assertEquals(0, Sky.at(60).sun);+ assertEquals(0, Sky.at(1400).sun);+ }++ @Test+ public void theGlowTracksTheSunFromLeftToRight() {+ assertTrue(Sky.at(390).sunX < Sky.at(780).sunX);+ assertTrue(Sky.at(780).sunX < Sky.at(1140).sunX);+ assertTrue(Sky.at(780).sunX > 0.4f && Sky.at(780).sunX < 0.6f); // midday is near the centre+ }++ @Test+ public void coloursInterpolateBetweenAnchors() {+ Sky.Palette dawn = Sky.at(390);+ Sky.Palette sunrise = Sky.at(450);+ Sky.Palette half = Sky.at(420);+ assertEquals(Sky.lerpColor(dawn.top, sunrise.top, 0.5f), half.top);+ assertNotEquals(dawn.top, half.top);+ assertNotEquals(sunrise.top, half.top);+ }++ @Test+ public void timeIsClampedAndAnsweredEveryMinuteOfTheDay() {+ assertEquals(Sky.at(0).top, Sky.at(-30).top);+ assertEquals(Sky.at(1440).top, Sky.at(4000).top);+ for (int minute = 0; minute < 1440; minute += 5) {+ Sky.Palette p = Sky.at(minute);+ double top = luma(p.top);+ double mid = luma(p.mid);+ // The header and the clock sit on the top two thirds; they stay on dark ground all day.+ assertTrue("top too bright at " + minute, top < 0.4);+ assertTrue("mid too bright at " + minute, mid < 0.4);+ }+ assertEquals(1439, Sky.minuteOfDay(23, 59));+ assertEquals(0, Sky.minuteOfDay(0, 0));+ }++ /** Rough relative brightness of an opaque ARGB colour, 0 to 1. */+ private static double luma(int color) {+ return (0.2126 * ((color >> 16) & 0xFF) + 0.7152 * ((color >> 8) & 0xFF) + 0.0722 * (color & 0xFF)) / 255.0;+ }+}diff --git a/themes/README.md b/themes/README.mdindex 02634cc2d..5e767cbcb 100644--- a/themes/README.md+++ b/themes/README.md@@ -36,6 +36,7 @@ is ignored, and a file that doesn't parse is ignored as a whole, so a theme can| `vpn_app` | string | App the network pill opens when a VPN is configured; also shows a red "VPN off" badge while no VPN is up || `show_home_settings_shortcut` | bool | The "Default home" tile, where the TV has a home picker || `background_color` | `#RRGGBB` | Colour behind everything; black by default |+| `sky_intensity` | 0 to 100 | Time-of-day backdrop: a dark gradient that follows the clock, 0 hides it (default) || `wallpaper` | bool | Show `wallpaper.jpg` from the theme folder (`true`), or ignore it (`false`) |## Wallpapers@@ -55,6 +56,19 @@ Android 10 is the known case. The default, `false`, keeps the normal motion.{ "reduced_motion": true }```+## Time-of-day backdrop++`"sky_intensity": 60` draws a dark gradient behind everything — wallpaper included — that follows the+clock: night blues, a soft blue day, then a warm horizon that peaks just before eight in the evening.+The glow near the bottom edge travels from left to right with the sun. The colours stay dark so the+white clock, the hero name and the dock band keep their contrast. It is drawn as one 480×270 bitmap+and redrawn once a minute, never animated, so even a 1 GB TV has nothing to keep up with. `0` keeps+the plain background; the default is off (the reference launcher looks exactly as before).++```json+{ "sky_intensity": 60 }+```+## Adding a themeOpen a PR with a new folder here, a one-line row in the table above and a screenshot from a real TV