Skip to content

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

Launcher: fade_rows, the rows fade out under the clock instead of being cut off

mrk19878bcf0dc600b8
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 6071c886f..b02e1293d 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -169,6 +169,8 @@ final class Config {
final boolean ambientGlow;
/** The focus highlight in the focused app's colour on every tile (config.xml, app_glow), as cinematic_home does for the dock. */
final boolean appGlow;
+ /** The rows fade out under the clock instead of being cut off (config.xml, fade_rows); TopFade. */
+ final boolean fadeRows;
/** Minutes Home may sit untouched before the clock screensaver (config.xml, home_idle_clock_minutes); 0 is off. */
final int homeIdleClockMinutes;
/** The dock band as light frosted glass like the pills (config.xml, dock_glass); false keeps the solid band. */
@@ -196,7 +198,7 @@ final class Config {
int[] settingsKeycodes, boolean settingsKeyPanel, boolean restoreKeyServices, boolean wallpaperEnabled, File wallpaper, List<File> wallpapers,
int wallpaperRotationMinutes, int wallpaperDim, int dockOpacity, String wallpaperOrder, boolean overlayApplied,
Festival festival, int[] inputKeycodes, List<String> appKeys, String stockHomeRedirect,
- List<RaceWeekend.Race> raceCalendar, boolean cinematicHome, boolean ambientGlow, boolean appGlow, int homeIdleClockMinutes,
+ List<RaceWeekend.Race> raceCalendar, boolean cinematicHome, boolean ambientGlow, boolean appGlow, boolean fadeRows, int homeIdleClockMinutes,
boolean keyFilter, boolean dockGlass, String glowStyle, boolean wallpaperCaptions,
boolean handleViewInputs, boolean tileMenu, boolean dockEvenPadding) {
this.handleViewInputs = handleViewInputs;
@@ -266,6 +268,7 @@ final class Config {
this.cinematicHome = cinematicHome;
this.ambientGlow = ambientGlow;
this.appGlow = appGlow;
+ this.fadeRows = fadeRows;
this.homeIdleClockMinutes = homeIdleClockMinutes;
this.dockGlass = dockGlass;
this.dockEvenPadding = dockEvenPadding;
@@ -342,6 +345,7 @@ final class Config {
boolean cinematic = res.getBoolean(R.bool.cinematic_home);
boolean ambientGlow = res.getBoolean(R.bool.ambient_glow);
boolean appGlow = res.getBoolean(R.bool.app_glow);
+ boolean fadeRows = res.getBoolean(R.bool.fade_rows);
int idleClockMinutes = res.getInteger(R.integer.home_idle_clock_minutes);
boolean keyFilter = res.getBoolean(R.bool.key_filter);
boolean dockGlass = res.getBoolean(R.bool.dock_glass);
@@ -412,6 +416,7 @@ final class Config {
cinematic = bool(json, "cinematic_home", cinematic);
ambientGlow = bool(json, "ambient_glow", ambientGlow);
appGlow = bool(json, "app_glow", appGlow);
+ fadeRows = bool(json, "fade_rows", fadeRows);
idleClockMinutes = integer(json, "home_idle_clock_minutes", idleClockMinutes, 0, 1440);
keyFilter = bool(json, "key_filter", keyFilter);
dockGlass = bool(json, "dock_glass", dockGlass);
@@ -469,7 +474,7 @@ final class Config {
shamsi, greetingName, moduleCards, reducedMotion, bootToLiveTv, dockTitle, dockRow, topMenu, launcherSettingsButton, reorderButton, showNetworkPill, showInputsPill, iconOnlyButtons, iconOnlyInputs, libraryButton, wifiLabelWidth, alwaysShowNames, wallpaperTrueColor, focusOvershoot, vpn, homeSettings, showStats, library, background,
Math.max(0, Math.min(100, skyIntensity)), settingsKeycodes, settingsKeyPanel, restoreKeyServices, wallpaperEnabled, wallpaper,
wallpapers, rotationMinutes, wallpaperDim, dockOpacity, wallpaperOrder, applied,
- festival, inputKeycodes, appKeys, stockHomeRedirect, json == null ? Collections.emptyList() : raceCalendar(json), cinematic, ambientGlow, appGlow,
+ festival, inputKeycodes, appKeys, stockHomeRedirect, json == null ? Collections.emptyList() : raceCalendar(json), cinematic, ambientGlow, appGlow, fadeRows,
Math.max(0, idleClockMinutes), keyFilter, dockGlass, glowStyle, wallpaperCaptions, handleViewInputs, tileMenu, dockEvenPadding);
}
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 5be43c946..b048d119a 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -501,6 +501,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
}
});
if (dockRow) grid.addItemDecoration(new DockDecoration(COLUMNS, density, cinematic, cfg.alwaysShowNames, cfg.dockOpacity, cfg.dockGlass, cfg.dockEvenPadding));
+ if (cfg.fadeRows) TopFade.attach(grid, 48 * density);
// Reduced motion: the tiles are simply there, with no entrance (reloadApps skips it there too).
if (animations && !reducedMotion) {
grid.setLayoutAnimation(new LayoutAnimationController(
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/TopFade.java b/launcher/app/src/main/java/com/gathin/tvhome/TopFade.java
new file mode 100644
index 000000000..7111d4a8d
--- /dev/null
+++ b/launcher/app/src/main/java/com/gathin/tvhome/TopFade.java
@@ -0,0 +1,53 @@
+package com.gathin.tvhome;
+
+import android.graphics.Canvas;
+import android.graphics.LinearGradient;
+import android.graphics.Paint;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffXfermode;
+import android.graphics.Shader;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+/**
+ * fade_rows: the rows fade out as they scroll up under the clock, instead of being cut off at the grid's top
+ * edge. It erases the top of the grid's own picture, so whatever is behind Home (a wallpaper, the sky) shows
+ * through; the grid draws into a hardware layer for that ({@link #attach}), or the erasing would punch through
+ * the whole window. Android's own requiresFadingEdge draws its fade in the wrong place with this grid's
+ * clipChildren=false, so it is not used. The fade grows in over the first pixels of scrolling, so the dock at
+ * rest is untouched.
+ */
+final class TopFade extends RecyclerView.ItemDecoration {
+
+ private final float length;
+ private final Paint paint = new Paint();
+ private float shaderHeight = -1f;
+
+ private TopFade(float length) {
+ this.length = length;
+ paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
+ }
+
+ static void attach(RecyclerView grid, float length) {
+ grid.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ grid.addItemDecoration(new TopFade(length));
+ }
+
+ /** How tall the fade is after scrolling {@code scrolled} pixels: nothing at rest, then up to {@code length}. */
+ static float height(int scrolled, float length) {
+ return Math.max(0f, Math.min(length, scrolled));
+ }
+
+ @Override
+ public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
+ float fade = height(parent.computeVerticalScrollOffset(), length);
+ if (fade <= 0f) return;
+ if (fade != shaderHeight) {
+ paint.setShader(new LinearGradient(0f, 0f, 0f, fade, 0xFF000000, 0x00000000, Shader.TileMode.CLAMP));
+ shaderHeight = fade;
+ }
+ c.drawRect(0f, 0f, parent.getWidth(), fade, paint);
+ }
+}
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index f600676d0..2b464c264 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -313,6 +313,10 @@
<!-- The focus highlight glows in the focused app's colour on every tile, as the cinematic shelf does for the
dock, without cinematic_home. Can also be set with "app_glow": true in a theme's config.json. -->
<bool name="app_glow">false</bool>
+ <!-- The rows fade out as they scroll up under the clock, instead of being cut off at a hard line (TopFade).
+ The grid then draws into a hardware layer, about 6 MB of graphics memory at 1080p, so it is off by default.
+ Can also be set with "fade_rows": true in a theme's config.json. -->
+ <bool name="fade_rows">false</bool>
<!-- Minutes Home may sit untouched before it shows the clock screensaver (ClockActivity); 0 turns it off.
Unlike the system screensaver this never starts over live TV or an app, which matters on TVs whose
Live TV window does not keep the screen on (CVTE): there the system screensaver would start in the
diff --git a/launcher/app/src/test/java/com/gathin/tvhome/TopFadeTest.java b/launcher/app/src/test/java/com/gathin/tvhome/TopFadeTest.java
new file mode 100644
index 000000000..305ea3879
--- /dev/null
+++ b/launcher/app/src/test/java/com/gathin/tvhome/TopFadeTest.java
@@ -0,0 +1,27 @@
+package com.gathin.tvhome;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/** Plain JVM tests for fade_rows: how tall the fade at the grid's top edge is for a given scroll. */
+public class TopFadeTest {
+
+ @Test
+ public void theDockAtRestIsUntouched() {
+ assertEquals(0f, TopFade.height(0, 72f), 0f);
+ assertEquals(0f, TopFade.height(-5, 72f), 0f); // an overscroll never fades anything
+ }
+
+ @Test
+ public void theFadeGrowsInWithTheFirstPixelsOfScrolling() {
+ assertEquals(10f, TopFade.height(10, 72f), 0f);
+ assertEquals(71f, TopFade.height(71, 72f), 0f);
+ }
+
+ @Test
+ public void thenItStaysAtItsFullLength() {
+ assertEquals(72f, TopFade.height(72, 72f), 0f);
+ assertEquals(72f, TopFade.height(5000, 72f), 0f);
+ }
+}
diff --git a/themes/README.md b/themes/README.md
index c0b455181..22fda331e 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -102,6 +102,7 @@ is ignored, and a file that doesn't parse is ignored as a whole, so a theme can
| `dock_glass` | bool | The dock band as light frosted glass like the top bar's pills (`false` by default); suits `sky_intensity` or a wallpaper, where the solid band reads as a dark slab |
| `ambient_glow` | bool | The glow behind the dock in the focused app's colour (`true` by default); `false` keeps only `background_color` or the wallpaper, e.g. for a calm photo background |
| `app_glow` | bool | The focus highlight glows in the focused app's colour on every tile, as `cinematic_home` does for the dock (`false` by default) |
+| `fade_rows` | bool | The rows fade out as they scroll up under the clock instead of being cut off at a hard line; the wallpaper or sky shows through. The grid then draws into a hardware layer (about 6 MB of graphics memory at 1080p) (`false` by default) |
## Wallpapers