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: the screensaver follows Home's collection, order and moods
leohoaree3cf548f6701
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/ClockScene.java b/launcher/app/src/main/java/com/gathin/tvhome/ClockScene.javaindex 8457b6683..dcae93ad7 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/ClockScene.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/ClockScene.java@@ -17,7 +17,13 @@ import android.view.View;import android.widget.ImageView;import java.io.File;+import java.time.LocalDateTime;+import java.time.ZoneId;+import java.util.ArrayList;+import java.util.List;+import java.util.Map;import java.util.Random;+import java.util.Set;/*** The clock screensaver's scene (layout dream_clock): the thin clock and date on black over a slow ambient@@ -46,13 +52,15 @@ final class ClockScene {private File wallpaperFile;private int wallpaperShade;private Resources wallpaperRes;- /** Bumped by stop(): a decode started before it finds a different number and drops its result. Main thread only. */+ /** One number per decode request: a result whose number is no longer the current one is dropped. Main thread only. */private int wallpaperGeneration;- /** clock_wallpaper with a collection: the pictures, the one in use, and how long each lasts. */- private java.util.List<File> rotation;- private int rotationIndex;+ /** clock_wallpaper with a collection: the pictures, how long each lasts, and how the next one is picked. */+ private List<File> rotation;private long rotationMs;private long shownMs;+ private String order;+ private Map<String, Set<String>> moods;+ private String latitude, longitude;private final Runnable tick = new Runnable() {@Override@@ -95,9 +103,10 @@ final class ClockScene {}/**- * clock_wallpaper: put Home's wallpaper (the theme's single picture, or the first of its collection) behind- * the clock, darkened by clock_wallpaper_dim, in place of the glow. Decoded off the main thread at screen size- * in RGB_565 (4 MB at 1080p), like Home's own; until then, or if it cannot be read, the glow stays.+ * clock_wallpaper: put the picture Home is showing behind the clock, darkened by clock_wallpaper_dim, in+ * place of the glow, and carry a collection's rotation on while the screensaver is up. Decoded off the main+ * thread at screen size in RGB_565 (4 MB at 1080p), like Home's own; until then, or if it cannot be read,+ * the glow stays.* Call before start(), which starts the decode (again after a stop() that dropped an unfinished one).*/void useHomeWallpaper(Context ctx) {@@ -115,29 +124,25 @@ final class ClockScene {}return;}- if (cfg.wallpaper != null) {- wallpaperFile = cfg.wallpaper;- } else if (cfg.wallpapers.isEmpty()) {+ // What Home plays, and Config puts the single wallpaper in it when a theme has no collection.+ // Reading cfg.wallpaper first held the screensaver on wallpaper.jpg while Home rotated.+ if (cfg.wallpapers.isEmpty()) {wallpaperFile = null;} else {// Start on the picture Home is showing. WallpaperPlayer records it under the same// preferences and the screensaver runs in the same process, so this is just a read.- // Taking wallpapers.get(0) instead meant a rotating theme showed the screensaver a- // different picture to the one behind Home.- rotation = new java.util.ArrayList<>(cfg.wallpapers);+ rotation = new ArrayList<>(cfg.wallpapers);String shown = ctx.getSharedPreferences("wallpaper_rotation", Context.MODE_PRIVATE).getString("image", "");- for (int i = 0; i < rotation.size(); i++) {- if (rotation.get(i).getName().equals(shown)) {- rotationIndex = i;- break;- }- }- wallpaperFile = rotation.get(rotationIndex);+ File current = WallpaperRotation.find(rotation, shown);+ wallpaperFile = current != null ? current : rotation.get(0);// Home only rotates while it is visible, so the screensaver carries the rotation on// itself; without this it holds one picture for as long as it is up.- rotationMs = cfg.wallpaperRotationMinutes > 0- ? cfg.wallpaperRotationMinutes * 60_000L : 0L;+ rotationMs = cfg.wallpaperRotationMinutes * 60_000L;+ order = cfg.wallpaperOrder;+ moods = cfg.wallpaperMoods;+ latitude = moods.isEmpty() ? "" : ctx.getString(R.string.latitude);+ longitude = moods.isEmpty() ? "" : ctx.getString(R.string.longitude);}wallpaperShade = (cfg.clockWallpaperDim * 255 / 100) << 24;wallpaperRes = ctx.getResources();@@ -149,7 +154,7 @@ final class ClockScene {Resources res = wallpaperRes;DisplayMetrics dm = res.getDisplayMetrics();int w = dm.widthPixels, h = dm.heightPixels;- int generation = wallpaperGeneration;+ int generation = ++wallpaperGeneration;new Thread(() -> {Bitmap bmp = decode(file, w, h);if (bmp == null) return;@@ -199,12 +204,24 @@ final class ClockScene {shownMs += MOVE_MS;if (shownMs < rotationMs) return;shownMs = 0;- rotationIndex = (rotationIndex + 1) % rotation.size();- wallpaperFile = rotation.get(rotationIndex);+ // The same pick as Home's, so a shuffled collection stays shuffled and wallpaper_moods still+ // decides what may show at this hour.+ File next = WallpaperRotation.pick(playable(), wallpaperFile.getName(), order, random);+ if (next.equals(wallpaperFile)) return; // a mood group of one+ wallpaperFile = next;wallpaperShown = false;loadWallpaper();}+ /** WallpaperPlayer's filter: the pictures wallpaper_moods allows at this hour, or all of them. */+ private List<File> playable() {+ if (moods.isEmpty()) return rotation;+ LocalDateTime now = LocalDateTime.now();+ int[] sun = WallpaperMood.sun(now.toLocalDate(), latitude, longitude, ZoneId.systemDefault());+ return WallpaperMood.select(rotation, moods,+ WallpaperMood.timeOfDay(now.getHour() * 60 + now.getMinute(), sun[0], sun[1]));+ }+private void moveClock() {content.animate().alpha(0f).setDuration(900).withLayer().withEndAction(() -> {placeClock();