Skip to content

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

Merge PR #231: optional time-of-day sky backdrop (off by default)

Gathin23b50bc03fc916
diff --cc launcher/app/src/main/java/com/gathin/tvhome/Config.java
index b6469de8b,e70d2617d..66f2a988a
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@@ -61,9 -57,9 +63,9 @@@ final class Config
private Config(List<String> dockApps, List<String> hiddenApps, String liveTvPackage, String liveTvAction,
String sourcePanelService, String sourcePanelAction, String inputAction,
- int columns, int rowsBelowDock,
+ int columns, int rowsBelowDock, boolean animations, boolean advancedEffects,
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);
@@@ -134,56 -126,17 +138,58 @@@
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);
}
+ // A theme push or reset invalidates choices made on the TV. On first use, remember the
+ // current theme without clearing choices from an older launcher version.
+ SharedPreferences choices = ctx.getSharedPreferences(SETTINGS_NAME, Context.MODE_PRIVATE);
+ syncThemeChoices(choices, dir, file);
+ int chosenColumns = choices.getInt("columns", columns);
+ if (chosenColumns >= 4 && chosenColumns <= 7) columns = chosenColumns;
+ animations = choices.getBoolean("animations", animations);
+ advancedEffects = choices.getBoolean("advanced_effects", advancedEffects);
File wallpaper = dir != null ? new File(dir, WALLPAPER_NAME) : null;
if (wallpaper != null && !(wallpaper.isFile() && wallpaper.length() > 0)) wallpaper = null;
// A theme can also switch the wallpaper off while the file is still there.
if (json != null && json.has("wallpaper") && !bool(json, "wallpaper", true)) wallpaper = null;
return new Config(dock, hidden, liveTv, liveTvAction, panelService, panelAction, inputAction,
- Math.max(1, columns), Math.max(0, rowsBelow), shamsi, moduleCards, reducedMotion,
- vpn, homeSettings, background, Math.max(0, Math.min(100, skyIntensity)),
- wallpaper, applied);
+ Math.max(1, columns), Math.max(0, rowsBelow), animations, advancedEffects,
- shamsi, moduleCards, reducedMotion, vpn, homeSettings, background, wallpaper, applied);
++ shamsi, moduleCards, reducedMotion, vpn, homeSettings, background,
++ Math.max(0, Math.min(100, skyIntensity)), wallpaper, applied);
+ }
+
+ private static void syncThemeChoices(SharedPreferences choices, File dir, File config) {
+ File revision = dir == null ? null : new File(dir, THEME_REVISION_NAME);
+ String token = revisionToken(revision);
+ String signature = fileStamp(config) + ":" + token;
+ String seen = choices.getString(THEME_SIGNATURE_KEY, null);
+ if (seen == null) {
+ // Existing preferences survive an app upgrade, unless the first launch follows an
+ // explicit theme push or reset by the updated tools.
+ SharedPreferences.Editor editor = choices.edit();
+ if (!"absent".equals(token)) editor.remove("columns").remove("animations")
+ .remove("advanced_effects");
+ editor.putString(THEME_SIGNATURE_KEY, signature).commit();
+ } else if (!seen.equals(signature)) {
+ choices.edit().remove("columns").remove("animations").remove("advanced_effects")
+ .putString(THEME_SIGNATURE_KEY, signature).commit();
+ }
+ }
+
+ private static String fileStamp(File file) {
+ return file != null && file.isFile() ? file.length() + "@" + file.lastModified() : "absent";
+ }
+
+ private static String revisionToken(File file) {
+ if (file == null || !file.isFile() || file.length() > 64) return "absent";
+ try (InputStream in = new FileInputStream(file)) {
+ byte[] bytes = new byte[(int) file.length()];
+ int n = in.read(bytes);
+ return n > 0 ? new String(bytes, 0, n, StandardCharsets.US_ASCII) : "absent";
+ } catch (Exception ignored) {
+ return "absent";
+ }
}
/** Reads and parses the overlay; any problem means "no overlay", never a crash on the home screen. */
diff --cc launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
index 30a1d3dd3,f813631ab..2b72f2ee5
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@@ -207,11 -200,10 +210,13 @@@ public class MainActivity extends Activ
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);
+ // The glow is one bitmap, so its alpha can be applied while drawing it. Otherwise every frame of
+ // a fade renders it into a full-screen offscreen buffer first.
+ ambient.forceHasOverlappingRendering(false);
heroName = findViewById(R.id.heroName);
greeting = findViewById(R.id.greeting);
btnWifi = findViewById(R.id.btnWifi);
diff --cc launcher/app/src/main/java/com/gathin/tvhome/SkyView.java
index 000000000,19ea27a7a..3f23d6102
mode 000000,100644..100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/SkyView.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/SkyView.java
@@@ -1,0 -1,98 +1,104 @@@
+ 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 {
+
++ /** Full-screen and faded with setAlpha: without this every redraw of Home goes through an offscreen layer. */
++ @Override
++ public boolean hasOverlappingRendering() {
++ return false;
++ }
++
+ 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 --cc themes/README.md
index b6e0f4f48,5e767cbcb..e9ef44ba4
--- a/themes/README.md
+++ b/themes/README.md
@@@ -36,10 -34,9 +36,11 @@@ is ignored, and a file that doesn't par
| `module_cards` | bool | Look for module cards and ask about them (`true`); `false` turns the feature off |
| `reduced_motion` | bool | Calmer motion for weak GPUs: stiff highlight spring, no tile overshoot, short fades, no entrance replay |
| `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 |
+| `animations` | bool | Basic focus, glass, title and tile entrance motion; true by default |
+| `advanced_effects` | bool | Optional lifted tile, icon zoom, smooth ambient colour and app opening effects; false by default |
+| `show_home_settings_shortcut` | bool | Keep the optional Default-home tile visible when the TV has a home picker; false by default |
| `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
@@@ -59,6 -56,19 +60,19 @@@ Android 10 is the known case. The defau
{ "reduced_motion": true }
```
+ ## Time-of-day backdrop
+
-`"sky_intensity": 60` draws a dark gradient behind everything — wallpaper included — that follows the
++`"sky_intensity": 60` draws a dark gradient over the wallpaper and behind everything else, 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 theme
Open a PR with a new folder here, a one-line row in the table above and a screenshot from a real TV